是否可以“刷新”WPF数据绑定 [英] Is it possible to 'refresh' WPF data bindings
问题描述
所以在调试器中看时,当我切换到一个新的选定项目,我看到非用户代码首先检查所有3个属性的值,然后只有前两个,最终只有第一个。但是,如果我更改标签并更改,似乎给了我另外一些用途。
绑定本身是非常简单的。一个布尔属性的TwoWay绑定到IsChecked。它是4级深度(Path = DataModel.Selected.AB),但我有其他的东西在相同的深度,工作正常。
这是人们听到的和知道可能会发生什么?或者如果绑定在某种程度上被忘记了,有没有办法明确提醒xaml?
这显然是一个已知问题:
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/8eb8280a-19c4-4502-8260-f74633a9e2f2/ 简而言之,一个RadioButton(通过.Net 3.5sp1)以某种方式杀死其他RadioButtons的绑定,当它被选中时,试图取消选中任何其他按钮。简单的修复(阅读:hack)是为每个单选按钮分配一个不同的GroupName,然后他们不要试图混淆eachother
I've got a xaml TabControl and on one page, there are 3 RadioButtons each bound to a different property on the selected value of an adjacent ListView. After switching between selected items in the ListView, my radio buttons seem to forget they're bound and don't refresh.
So watching it in the debugger, when I switch to a new selected item, I see the non user code first checking the value on all 3 properties, then only the first two, and eventually only the first. However, if I change the tab and change back, it seems to give me another few uses.
The binding itself is fairly straightforward. a TwoWay binding of a bool property to IsChecked. It's 4 levels deep (Path=DataModel.Selected.A.B), but I have other things at the same depth that work fine.
Is this something people have heard about and know what might be going on? Or if the binding is somehow getting forgotten, is there a way to explicitly remind the xaml?
This is apparently somewhat of a known issue:
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/8eb8280a-19c4-4502-8260-f74633a9e2f2/
In short, a RadioButton (through .Net 3.5sp1) somehow kills bindings of other RadioButtons when when it's checked while trying to uncheck any other buttons. The simple fix (read: hack) is to assign each radiobutton a different GroupName and then they don't try to mess with eachother
这篇关于是否可以“刷新”WPF数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!