|
How about:
<CheckBox Content="I'm Checked!" IsChecked="True"/>
or, in code:
theCheckbox.IsChecked = true;
Now, I'm a bit puzzle by what you mean "in the event handler"
You don't set it in the event handler (that would be pointless and against the normal behavior of a checkbox), you get the new value!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
modified on Monday, August 31, 2009 9:00 PM
|
|
|
|
|
Super Lloyd wrote: <CheckBox Content="I'm Checked!" IsChecked="True"/>
I can't set the initial state of the checkbox in the XAML, since the initial state is determined programmatically during the Loaded() event handler for the dialog.
Super Lloyd wrote: Now, I'm a bit puzzle by what you mean "in the event handler"
I'm referring to something like this, where a flag tells the CheckBox Checked() handler whether or not to do its thing:
bool _SettingInitialState = true;
_SettingInitialState = true;
_Checkbox.IsChecked = initial_state;
_SettingInitialState = false;
private void _CheckedHandler(...)
{
if (!_SettingInitialState)
{
}
}
Software Zen: delete this;
|
|
|
|
|
why don't you set it in the Loaded event handler then, if it's when it is decided?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
That's where I want to set it. I'd just like the act of setting the initial state to not trigger the Checked handler when I do so.
Software Zen: delete this;
|
|
|
|
|
Mmm, strange, why is it you can't decide of the checked state before, maybe you are not doing something the elegant way perhaps?
Anyway, to suggest an other unelegant workaround, why don't you register the event handler by code in the Loaded event handler (after setting the value), instead of registering it in XAML?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Super Lloyd wrote: Mmm, strange, why is it you can't decide of the checked state before, maybe you are not doing something the elegant way perhaps?
Setting the state depends upon communications with an external process, which may take a significant amount of time. Until that communication completes, I don't know the state.
I may simply connect the event handler when the communication completes, instead of in the Loaded() handler.
Thanks for the suggestions .
Software Zen: delete this;
|
|
|
|
|
Hi
I have an enum set say tiger=0,
lion=1,
deer=2,
snake=4
These enums are to be displayed in a list box which is dependent on a combo box. The combo box will have values like carnivores,herbivores,repltiles.
So when I change my selectedindex the value in the list box(ie the animal names) should also change. So if I have carnivores, I get lion and tiger. If i have reptiles , I have snake.
Please suggest the respective xaml and the necessary code required. Its very urgent.
Thanks
|
|
|
|
|
So how do you tell from the enum whether the animal is a carnivore? You can't, so you have to..."Its very urgent.". Of course it's urgent to you, but not to everyone else here who volunteer their time. Don't be rude.
only two letters away from being an asset
|
|
|
|
|
Am not being rude...
neways.. lion = animal.carnivore
snake = animal.reptile
and so on..
hope this helps...
|
|
|
|
|
To be clear, when you ask for an urgent response here you are being rude. Everyone here volunteers their time and to ask for an urgent response you are failing to recognize this, and thus being rude and inconsiderate. We don't have to answer your question immediately, or at all, do demand it.
You have your answer already if you think about it. Based on the selection from one dropdown you need to populate a second. How would you do this? How do you populate the first dropdown?
only two letters away from being an asset
|
|
|
|
|
Ok ok... am sorrry... not familiar with the "Posting" standards.
I got ur point, but the problem is with the enums.... if it was a normal list, it was simple... but the enums are creating a problem..
Please do help
|
|
|
|
|
ProgrammerWPF wrote: if it was a normal list, it was simple
An enum can be treated like a "normal" list, Enum.GetNames[^] returns an array of the enum names. Enum.GetValues[^] returns an array values. You can either use one of these methods or create a collection that combines them into name/value pairs and bind your dropdown to it.
only two letters away from being an asset
|
|
|
|
|
If you need to bind to an enumeration, you can find details here[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi guys
I use the following code (binding-a-treeview-to-a-dataset/[^]) to bind my treeview to a dataset:
<objectdataprovider x:key="dataSetProvider" methodname="GetRangeProductsDataSet" objecttype="{x:Type local:DataSetCreator}">
<DataTemplate x:Key="RangeDetailTemplate">
<TextBlock Text="{Binding Product}"/>
</DataTemplate>
<HierarchicalDataTemplate x:Key="RangesTemplate" ItemsSource="{Binding RangeProducts}" ItemTemplate="{StaticResource RangeDetailTemplate}">
<TextBlock Text="{Binding ProductRangeDesc}"/>
</HierarchicalDataTemplate>
<TreeView DataContext="{StaticResource dataSetProvider}" ItemsSource="{Binding ProductRange}" ItemTemplate="{StaticResource RangesTemplate}"
Margin="143.75,2.723,8,36" Name="treeViewRangeStartup"
Background="Transparent"></TreeView>"
Then it gives me some error saying that the path to my database does not exist, and it won't load the designer. When I run the app though, it works fine, showing me all the nodes as well as all extending tree nodes. There can'be something wrong with my connectionstring because I didn't change it. And before I used a dataset to bind to a treeview, I used an XML file to bind to bind to the treeview. This gave me no errors even though I was using exactly the same database with exactly the same connection string etc.
Any hints to what might cause this?
modified on Monday, August 31, 2009 1:38 PM
|
|
|
|
|
Also note, the database I'm using resides in a folder within my solution directory, so I'm not accessing a database on a server whatsoever.
In the error list it displays a certain database path, and it says that this path is incorrect, but nowhere in my path did I specify this path. The folder names are correct though, but the directory that the error message displays is exactly 2 folders back from where my database actually is
|
|
|
|
|
Hi,
I am working on a silverlight application. In this I need to upload images and save them in the database.
If anyone have any idea to solve this please reply me.
Thanks in advance
|
|
|
|
|
I found a nice Example[^] here... Hope it helps..
|
|
|
|
|
Hello to all
I can't access the visual éléments of a wpf listbox
I'm trying to find the scrollviewer but impossible...
Here is the bit of code:
Dim i As Integer
Dim child As Object
For i = 0 To i <= VisualTreeHelper.GetChildrenCount(monListBox)
child = VisualTreeHelper.GetChild(monListBox, i)
If TypeOf (child) Is ScrollViewer Then
SV_ShowCalendarPanel = child
End If
Next
The trouble is that "VisualTreeHelper.GetChildrenCount(monListBox)" get me O all the time,
and then, of course, the "GetChild" get me... nothing
All help will be welcome,
Yann.
|
|
|
|
|
Your logic isn't correct here. The child of a Listbox is a border, so you need to keep enumerating through the child visuals using a recursive method. This is an example piece of code which gets the ScrollViewer (in C# I'm afraid):
public ScrollViewer FindScrollViewer(Visual myVisual)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(myVisual); i++)
{
Visual child = (Visual)VisualTreeHelper.GetChild(myVisual, i);
if (child is ScrollViewer)
{
return child as ScrollViewer;
}
return FindScrollViewer(child);
}
return null;
} All you need do to call it is SV_ShowCalendarPanel = FindScrollViewer(monListBox);
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hello Pete,
Thanks for you answer.
Fidling around I finaly arrived at the same solution by myself.
By the way, I'm a big fan of your post...
Yann.
|
|
|
|
|
pkboo wrote: By the way, I'm a big fan of your post...
Thanks - it's always nice to know that people find what I write helpful.
pkboo wrote: Fidling around I finaly arrived at the same solution by myself.
Cool - you know you're getting better at WPF when you can sort things like this out.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I'm new to WPF and I'm having a bit of trouble figuring out images. I'm trying to load image files (png,gif,bmp,etc) from the hard drive, then allow pixel manipulation (changing the color and alpha) and saving them off again.
I know there are a lot of options for holding images; BitmapSource, Image, BitmapFrame... I just don't know what is best for what I'm working on! Any suggestions? And how would I get at the pixels to change them?
Thanks!
|
|
|
|
|
I've noticed something a bit annoying with wpf. If i spawn a window, and the monitor is sleeping, then my window doesn't get painted until you invalidate it by moving your mouse around it... clicking at it... or resizing it...
I've made a proof of concept vs.net solution to illustrate what i'm encountering: http://wolfsfiles.googlepages.com/SleepingMonitorWpfProblem.zip[^]
|
|
|
|
|
|
I embedded a ListBox in a DataGrid for displaying a List<string> in a GridCell. And I need to popup a ComboBox to select my data in the GridCell. The ComboBox is customied for multiple selection. However, when I click the cell (with ListBox embedded), the ComboBox can’t be activated. Here is the codesnip. Do I miss something? Or is the ListBox sucked in the mouse event from the DataGrid? TIA.
<br />
<data:DataGridTemplateColumn Header="Test"><br />
<data:DataGridTemplateColumn.CellTemplate><br />
<DataTemplate><br />
<controls1:DockPanel><br />
<ListBox controls1:DockPanel.Dock="Left" <br />
ItemsSource="{Binding TestNames}" VerticalAlignment="Center" /><br />
</controls1:DockPanel><br />
</DataTemplate><br />
</data:DataGridTemplateColumn.CellTemplate><br />
<data:DataGridTemplateColumn.CellEditingTemplate><br />
<DataTemplate><br />
<StackPanel Orientation="Vertical"><br />
<c:DataGridComboBox SelectedItem="{Binding TestInfo, Mode=TwoWay}" <br />
Style="{StaticResource MultiSelectComboBoxStyle}"<br />
DropDownOpened="DataGridComboBox_DropDownOpened"<br />
DisplayMemberPath="Name" <br />
c:DataGridComboBoxService.ForceOpen="true" Height="24" /><br />
</StackPanel><br />
</DataTemplate><br />
</data:DataGridTemplateColumn.CellEditingTemplate><br />
</data:DataGridTemplateColumn><br />
|
|
|
|