我是靠谱客的博主 着急钢笔,最近开发中收集的这篇文章主要介绍Wpf checkboxlist,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

<Window x:Class="WpfTests.CheckedListBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="CheckedListBox" Height="300" Width="300">
<ListBox ItemsSource="{Binding TheList}">
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected}" Content="{Binding TheText}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox> </Window>

 
using System; using System.Windows; using System.Collections.Generic; using System.Collections.ObjectModel;
namespace WpfTests {
public partial class CheckedListBox : Window
{
public ObservableCollection<BoolStringClass> TheList{ get; set; }
public CheckedListBox()
{
InitializeComponent();
TheList = new ObservableCollection<BoolStringClass>();
TheList.Add(new BoolStringClass { IsSelected = true, TheText = "Some text for item #1" });
TheList.Add(new BoolStringClass { IsSelected = false, TheText = "Some text for item #2" });
TheList.Add(new BoolStringClass { IsSelected = false, TheText = "Some text for item #3" });
TheList.Add(new BoolStringClass { IsSelected = false, TheText = "Some text for item #4" });
TheList.Add(new BoolStringClass { IsSelected = false, TheText = "Some text for item #5" });
TheList.Add(new BoolStringClass { IsSelected = true, TheText = "Some text for item #6" });
TheList.Add(new BoolStringClass { IsSelected = false, TheText = "Some text for item #7" });
this.DataContext = this;
}
}
public class BoolStringClass
{
public string TheText { get; set; }
public bool IsSelected { get; set; }
} }

转载于:https://www.cnblogs.com/dodui/archive/2012/05/18/2507961.html

最后

以上就是着急钢笔为你收集整理的Wpf checkboxlist的全部内容,希望文章能够帮你解决Wpf checkboxlist所遇到的程序开发问题。

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

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

评论列表共有 0 条评论

立即
投稿
返回
顶部