我是靠谱客的博主 开朗水蜜桃,最近开发中收集的这篇文章主要介绍checkbox wpf 绑定数组,WPF数据绑定CheckBox.IsChecked,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

How would I bind the IsChecked member of a CheckBox to a member variable in my form?

(I realize I can access it directly, but I am trying to learn about databinding and WPF)

Below is my failed attempt to get this working.

XAML:

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Title="Title" Height="386" Width="563" WindowStyle="SingleBorderWindow">

TabIndex="2" Margin="0,12,30,0"

Checked="checkBoxShowPending_CheckedChanged"

Height="17" Width="92"

VerticalAlignment="Top" HorizontalAlignment="Right"

Content="Show Pending" IsChecked="{Binding ShowPending}">

Code:

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

}

}

}

解决方案

Note i added a name to , and changed the binding in your CheckBox. You will need to implement ShowPending as a DependencyProperty as well if you want it to be able to update when changed.

最后

以上就是开朗水蜜桃为你收集整理的checkbox wpf 绑定数组,WPF数据绑定CheckBox.IsChecked的全部内容,希望文章能够帮你解决checkbox wpf 绑定数组,WPF数据绑定CheckBox.IsChecked所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部