如何在下一个窗口中传递选定的单选按钮并在 WPF 中显示为选定的?
我有一个带有数据网格 dgSample 的 WPF 窗口。它已绑定到如下列表 lstSample:
dgSample.itemssource=lstSample;
此数据网格还有一个单选按钮列,其中我通过单击单选按钮选择一行,然后,在单击下一个按钮后我可以移至下一页。在下一页上,再次出现相同的数据网格,具有相同的单选按钮列。我想要的是,当我到达此页面时,我希望在此处也选择上一页中选择的单选按钮。 我尝试通过以下方式将单选按钮列与 IsSelected
属性绑定:
IsChecked="{Binding Path IsSelected, Mode=TwoWay}"
但这不起作用。 我该怎么做才能让它发挥作用?
PS:与 xaml 相比,我更喜欢代码隐藏解决方案。
请帮忙!
I have a WPF Window with a datagrid dgSample
. it has been bound to a list lstSample like this:
dgSample.itemssource=lstSample;
this datagrid also has a radio button column wherein i select one row by clicking on the radio button, and then, i can move to the next page after i click on the next button. On the next page, there is again the same datagrid, with the same radiobutton column. What I want is, that when i reach this page, i want the radio button that was selected in the previous page to be selected here as well.
I have tried binding the radiobutton column with an IsSelected
Property by doing:
IsChecked="{Binding Path IsSelected, Mode=TwoWay}"
but this is not working.
What can I do to make it work?
P.S.: I prefer code-behind solution than the xaml one.
Please help !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的模型需要实现 INotifyPropertyChanged 并调用
以使其在另一个视图中更新。
注意:如果设置了,
则不必检查是否为空。
Your model needs to implement
INotifyPropertyChanged
and callto get it to update in another view.
NB: If you set
you won't have to check for null.