79086706

Date: 2024-10-14 15:13:50
Score: 0.5
Natty:
Report link

I do it this way in code behind:

    private void DataGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
        DataGridCell obj = (DataGridCell)Keyboard.FocusedElement;
        if (obj == null) { return; }
        if (obj.Content == null) { return; }
        if (obj.Content.GetType() == typeof(CheckBox))
        {
            CheckBox cb = (CheckBox)obj.Content;
            Point x = Mouse.GetPosition(cb);
            if (x.X < cb.ActualWidth && x.Y < cb.ActualHeight)
            {
                cb.IsChecked = (bool)cb.IsChecked ? false : true;
            }
        }
    }
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Reini