如何制作CheckEdit
全选。
Xaml 自动生成checkEdit
<ItemsControl ItemsSource="{Binding MyProperty, Mode=TwoWay}" Margin="0" Grid.Column="1" Grid.RowSpan="1" x:Name="MyCheck" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<dxe:CheckEdit Content="{Binding FilePath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Padding="2.5" Margin="3"
IsChecked="{Binding IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
<Button x:Name="filtrButton" Content="Filtr" Command="{Binding FiltrCommand}" Padding="5" Margin="3" IsEnabled="{Binding IsEnabled}"/>
<dxe:CheckEdit x:Name="CheckALL" Content="Select All" Padding="2.5" Margin="3" IsChecked="{Binding AllSelected}" />
C#
private bool? _allSelected = true;
public bool? AllSelected
{
get { return _allSelected; }
set
{
_allSelected = value;
MyProperty.ForEach(x => x.IsChecked = value);
OnPropertyChange("AllSelected");
}
}
public List<MyCheckBox> MyProperty
{
get { return TempList; }
set
{
TempList = value;
OnPropertyChange("MyProperty");
}
}
/// добавление название файла и его select
public ViewModel(){
TempList = new List<MyCheckBox>();
foreach (var type in tempUniqueList)
{
TempList.Add(new MyCheckBox(type, _allSelected));
}
MyProperty = TempList;
}