Gigi
Gigi

Reputation: 29471

Capturing indeterminate state in WPF Threestate Checkbox

So, I have a simple threestate checkbox in a WPF application:

<CheckBox Checked="CheckBox_Checked"
          Unchecked="CheckBox_Checked"
          IsThreeState="True" />

Now, I want this checkbox to do something whenever its state is changed, which is why I'm setting the Checked and Unchecked events to the same method in the view. Since this is just a very simple example, this is all I'm doing in that method:

    private void CheckBox_Checked(object sender, RoutedEventArgs e)
    {
        MessageBox.Show("Test");
    }

Now the problem is that while this works when the checkbox is checked or unchecked, nothing happens when its value is changed to the indeterminate state. It's clear that I'm setting events for Checked and Unchecked but missing some event for the indeterminate state.

What event do I need to use in order to take action when the indeterminate state is set?

Upvotes: 5

Views: 2286

Answers (1)

Gigi
Gigi

Reputation: 29471

Apparently to do this you need to use the Indeterminate event like so:

<CheckBox Checked="CheckBox_Checked"
          Unchecked="CheckBox_Checked"
          Indeterminate="CheckBox_Checked"
          IsThreeState="True" />

Upvotes: 7

Related Questions