Silverlight ComboBox Binding Issue [modified]
-
Hi all, I am making use of a DataForm to display my data. I have made use of the DataForm edit template to customize the layout of the form. Data is returned and is being displayed within the DataForm. The problem is that, as soon as I start navigating (2 navigation clicks) with the DataFrom, only the ComboBox 'looses' it's binding on the SelectedItem (although it's selected item was data bound and then it just goes blank :confused:). The back end code consists of a generic list
List
and a string variable that has the value of each data item that is returned... public List<string> Category { get; set; } public string CategoryName { get; set; } ..
The XAML code:... <dataFormToolkit:DataField DescriptionViewerPosition="Auto" LabelPosition="Left" LabelVisibility="Visible" Label="Category"> <ComboBox ItemsSource="{Binding Category}" SelectedItem="{Binding CategoryName, Mode=TwoWay}" /> </dataFormToolkit:DataField> ...
Any reason why this is happening and how I can fix it? Many thanks in advance. Kind regardsThe only programmers that are better C# programmers, are those who look like this -> :bob:
:java: Programm3r My Blog: ^_^
modified on Wednesday, December 30, 2009 8:36 AM
-
Hi all, I am making use of a DataForm to display my data. I have made use of the DataForm edit template to customize the layout of the form. Data is returned and is being displayed within the DataForm. The problem is that, as soon as I start navigating (2 navigation clicks) with the DataFrom, only the ComboBox 'looses' it's binding on the SelectedItem (although it's selected item was data bound and then it just goes blank :confused:). The back end code consists of a generic list
List
and a string variable that has the value of each data item that is returned... public List<string> Category { get; set; } public string CategoryName { get; set; } ..
The XAML code:... <dataFormToolkit:DataField DescriptionViewerPosition="Auto" LabelPosition="Left" LabelVisibility="Visible" Label="Category"> <ComboBox ItemsSource="{Binding Category}" SelectedItem="{Binding CategoryName, Mode=TwoWay}" /> </dataFormToolkit:DataField> ...
Any reason why this is happening and how I can fix it? Many thanks in advance. Kind regardsThe only programmers that are better C# programmers, are those who look like this -> :bob:
:java: Programm3r My Blog: ^_^
modified on Wednesday, December 30, 2009 8:36 AM
Hey. This problem has been bugging me a lot lately - Something really odd is happening in the framework. What's happening is the data field control is modifying the bindings on the control and re-setting them. Setting the SelectedItem works fine, but when it comes to re-set the ItemsSource property the binding for the *SelectedItem* property *vanishes* without a trace. The only workaround I have at the moment is to make the ItemsSource binding TwoWay, and ensuring that the property it's bound to is read-only. This stops the code from modifying the ItemsSource binding. However, I'm now finding that the bindings are disappearing under other circumstances as well (it looks like it's happening occasionally when there is more than 1 combo box in the form) - I haven't solved that one yet. Cheers, Mike