[英]How to update control inside ListBox item
我有一个ListBox
定义如下。 我在ListView
项目中有CheckBox
需要以编程方式检查/取消选中(只是想实现选择/取消选择所有操作)。 实现这一目标的最佳方法是什么?
<ListBox Margin="0,0,10,0" Name="listViewChanges" SelectionMode="Multiple">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<CheckBox x:Name="lblChangedSelected" IsChecked="{Binding Selected}" VerticalAlignment="Center" VerticalContentAlignment="Center" Margin="10,0,0,0"></CheckBox>
<Label x:Name="lblChangedStatus" Content="{Binding Status}" VerticalContentAlignment="Center"></Label>
<Label x:Name="lblChangedPath" Content="{Binding Path}" VerticalContentAlignment="Center"></Label>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
你应该拥有绑定工具INotifyPropertyChanged
背后的类。 然后,当您更改属性时,触发NotifyPropertyChanged
事件,绑定应自动更新。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.