我有一个ListBox
定义如下。我有需要以编程方式检查/取消选中CheckBox
的ListView
项目(只想实现全选/取消全选操作)。实现这一目标的最佳方法是什么?
<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>