Is it possible to “refresh” WPF data bindings

I have xaml TabControl and on one page there are 3 RadioButtons, each of which is bound to a different property in the selected value of the adjacent ListView. After switching between the selected items in the ListView, my switches seem to forget that they are connected and not updated.

Therefore, watching it in the debugger, when I switch to the new selected item, I see that it is not user code that first checks the value for all 3 properties, and then only the first two, and ultimately only the first. However, if I change the tab and change back, it seems to give me some more use cases.

The binding itself is pretty simple. binding TwoWay of the bool property to IsChecked. It has 4 depth levels (Path = DataModel.Selected.AB), but I have other things at the same depth that work fine.

Is this something that people have heard about and know what can happen? Or if the binding is somehow forgotten, is there a way to explicitly resemble xaml?

+4
source share
3 answers

This is apparently a somewhat known issue:

http://social.msdn.microsoft.com/forums/en-US/wpf/thread/8eb8280a-19c4-4502-8260-f74633a9e2f2/

In short, RadioButton (via .Net 3.5sp1) somehow kills the bindings of other RadioButtons when it is checked when trying to uncheck other buttons. A simple fix (read: hack) is to give each radio object a different GroupName, and then they don’t try to mess with eachother

+6
source

You can manually update the bindings as follows:

TestCheckBox .GetBindingExpression(CheckBox.IsCheckedProperty) .UpdateTarget(); 

Thus, I am not 100% sure that this will fix your underlying problem. I didn't have this type of WPF binding problem before, but I had some weird issues with the tab control.

+8
source

Another way to solve this problem is to fake the property list in the ListBox and create the ListBoxItem template as a radio.

+1
source

All Articles