选中在wpf中选择全部选中复选框

问题描述 投票:0回答:1

单击“全选”时如何单击所有复选框,取消选中“全选”时应取消选中。请告诉我 。

<ListBox ItemsSource="{Binding Inputbinding}" >
  <CheckBox x:Name="chkSelectAll" Content="Select All" />
  <CheckBox x:Name="chkjon" Content="Jon" />
  <CheckBox x:Name="chkbob" Content="Bob" />
 <CheckBox x:Name="chkmary" Content="Mary" />                
</ListBox>
 <Button  x:Name="btnUserName"  Height="25"  Margin="0,10,10,0"
      IsEnabled="{Binding Path=IsButtonEnabled,Mode=TwoWay}" Click="BtnInput_Click"  >
    <TextBlock >Submit</TextBlock>
</Button>
wpf checkbox listbox
1个回答
0
投票

试试这个:

   <CheckBox x:Name="chkSelectAll" Content="Select All" />
   <CheckBox x:Name="chkjon" Content="Jon" IsChecked="{Binding IsChecked,ElementName=chkSelectAll,Mode=OneWay}" />
   <CheckBox x:Name="chkbob" Content="Bob"  IsChecked="{Binding IsChecked,ElementName=chkSelectAll,Mode=OneWay}" />
   <CheckBox x:Name="chkmary" Content="Mary"  IsChecked="{Binding IsChecked,ElementName=chkSelectAll,Mode=OneWay}" />

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.