(我意识到我可以直接访问它,但我正在尝试学习数据绑定和WPF)
以下是我尝试让这个工作失败的尝试.
XAML:
<Window x:Class="MyProject.Form1"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"title="Title" Height="386" WIDth="563" window><GrID> <CheckBox name="checkBoxShowPending" TabIndex="2" margin="0,12,30,0" Checked="checkBoxShowPending_CheckedChanged" Height="17" WIDth="92" VerticalAlignment="top" HorizontalAlignment="Right" Content="Show Pending" IsChecked="{Binding ShowPending}"> </CheckBox></GrID></Window>
码:
namespace MyProject{ public partial class Form1 : Window { private ListVIEwColumnSorter lvwColumnSorter; public bool? ShowPending { get { return this.showPending; } set { this.showPending = value; } } private bool showPending = false; private voID checkBoxShowPending_CheckedChanged(object sender,EventArgs e) { //checking showPending.Value here. It's always false } }}解决方法
<Window ... name="MyWindow"> <GrID> <CheckBox ... IsChecked="{Binding Elementname=MyWindow,Path=ShowPending}"/> </GrID></Window>
注意我添加了一个名称< Window>,并更改了CheckBox中的绑定.如果您希望它在更改时能够更新,您还需要将ShowPending实现为DependencyProperty
.
以上是内存溢出为你收集整理的WPF数据绑定CheckBox.IsChecked全部内容,希望文章能够帮你解决WPF数据绑定CheckBox.IsChecked所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)