Bra*_*onS 21 data-binding wpf selected listboxitem
我有一个WPF ListBox
控件,我将其设置ItemsSource
为项目对象的集合.如何将对象的IsSelected
属性绑定ListBoxItem
到Selected
相应项对象的属性,而不将对象的实例设置为Binding.Source
?
Anv*_*aka 41
只需覆盖ItemContainerStyle:
<ListBox ItemsSource="...">
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="IsSelected" Value="{Binding Selected}"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
哦,对了,我想你想从dr.WPF这美妙的文章:ItemsControl中:A到Z.
希望这可以帮助.
归档时间: |
|
查看次数: |
16264 次 |
最近记录: |