如何在单击按钮时检查 DataGridCheckBoxColumn。因此,当我触发按钮单击事件时,我希望检查 DataGridCheckBoxColumn。
private void loadCheckBoxColumn()
{
MedicationDatagrid.Columns.Add( new DataGridCheckBoxColumn
{
Header = "Selected",
Binding = new Binding( "checkBox" )
} );
}
按钮点击事件:
private void btnchecked_Click( object sender, RoutedEventArgs e )
{
AwaitingMeds checkedItem = new AwaitingMeds();
List<AwaitingMeds> awaitingMedslist = MedicationDatagrid.ItemsSource as List<AwaitingMeds>;
buttonClickCheckedUnChecked();
if( !( ( AwaitingMeds )MedicationDatagrid.SelectedItem == null ) )
{
checkedItem.checkBox = true;
}
}
buttonClickCheckedUnChecked:
private void buttonClickCheckedUnChecked()
{
AwaitingMeds checkedItem = new AwaitingMeds();
if( checkedItem.checkBox == true )
{
btnunChecked.Visibility = Visibility.Visible;
}
else
{
btnunChecked.Visibility = Visibility.Collapsed;
}
}