我有一个ListBox包含复选框,DataTemplate并且有两个按钮“全选”和“取消全选”。我想通过单击选择和取消选择按钮来使该复选框选中所有并取消选中所有,我想INotifyPropertyChanged在课堂上实现。我怎样才能做到这些事情?
感谢您提前的回答..
XAML代码
<StackPanel>
<ListBox Name="lstUserDefination"
ScrollViewer.VerticalScrollBarVisibility="Auto" SelectionMode="Multiple">
<ListBox.ItemTemplate>
<DataTemplate>
<ListBoxItem>
<CheckBox Name="chkUser" Content="{Binding AuthorityName}"/>
</ListBoxItem>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
C# 代码
public partial class UserDefinationEdit : Window
{
public ObservableCollection<Authority> authorityList { get; set; }
public UserDefinationEdit()
{
InitializeComponent();
CreateCheckBoxList();
lstUserDefination.ItemsSource = authorityList;
}
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
DragMove();
}
}
public void CreateCheckBoxList()
{
authorityList = new ObservableCollection<Authority>();
authorityList.Add(new Authority() {AuthorityValue = 0, AuthorityName …Run Code Online (Sandbox Code Playgroud)