我是靠谱客的博主 着急钢笔,这篇文章主要介绍Wpf checkboxlist,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
<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>
复制代码
1

复制代码
1
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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内容请搜索靠谱客的其他文章。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部