如何在listview
(或listbox
)中添加已选中(或未选中)的商品?
我搜索了很长时间,但我总是在Windows窗体上找到关于CheckedListBox
对象和ListView.Checked
属性的主题,这些属性似乎不存在于WPF中。
我成功地使用活动目录中的某些组填充列表,但我不知道如何通过简单的检查(或隐藏它们)来显示它们。
我是否需要导入一些参考文献?
我正在使用VB.NET和Visual Studio Express 2012。
答案 0 :(得分:1)
您需要为ItemTemplate
:
ListBox
<ListBox ItemsSource="{Binding}" SelectionMode="Extended">
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType=ListBoxItem}}"
Content="{Binding}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>