1
votes

I have an application that uses the Xceed DataGrid for WPF. In it I have a column that has a checkbox and I would like the IsChecked or Checked event to call a function. Problem is with everything I've done I either get a running application that does nothing except toggle the check box or I get the following exception thrown:

Failed to create a 'Checked' from the text 'CheckBoxChecked'

All I would like to do is to somehow bind the checkbox to call a function when the user toggles it. I am still a bit new to the WPF binding framework. I have added the small snippet of code that I am using when creating the DataTemplate in regards to this column:

<DataTemplate>
    <StackPanel Orientation="Horizontal">
        <CheckBox Checked="CheckBoxChecked" />
    </StackPanel>
</DataTemplate>

Thanks in advance for any help.

1
IsChecked or Checked event to call a function. please clarify. IsChecked is not an event, its a DependencyProperty. also, what do you need to do exactly?Federico Berasategui
IsChecked and Checked is what I saw online in various forums on what to bind to. Pretty much I have a grid and in my grid I specify a checkbox using the xml above. What I would like to do is when the checkbox is toggled it would call on a function where I can perform my logic.Seb

1 Answers

1
votes

May I suggest you a more WPF-correct approach? You bind the checkbox to a property then react when this property is changed:

XAML:

<DataTemplate>
    <StackPanel Orientation="Horizontal">
        <CheckBox IsChecked="{Binding IsSomething}" />
    </StackPanel>
</DataTemplate>

In the class of your DataContext:

    private bool isSomething;
    public bool IsSomething
    {
        get { return isSomething; }
        set
        {
            isSomething = value;
            DoSomething();
        }
    }