Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
70
How to update bound property for checkbox column without needing to click outside cell?
posted

How to update bound property for checkbox column without needing to click outside cell?

I have a XamDatagrid with only one fields editable, which is a checkbox used for selecting items. When I change the value, the underlying bound property is not being updated until I click outside the cell. I tried playing with the grid's UpdateMode property but of no use.

This is very important as user click on the checkbox, they see it as the row is selected but when they perform an operation "Say delete", from the ribbon, which is supposed to delete the row.. is not being deleted. I tried to explain to users how it works.. but .. you know they are users.

Any help in this direction is appreciated.

thanks

Bhuvan

  • 385
    posted

    One of the posts suggested that you change the template to use a regular check box instead of the XamCheckBoxEditor:

    <

     

    ig:Field Name="SomeBooleanField" >

    <ig:Field.Settings>

    <

     

    ig:FieldSettings>

    <

     

    ig:FieldSettings.CellValuePresenterStyle>

    <Style TargetType="{x:Type ig:CellValuePresenter}">

     <

     

    Setter Property="Template">

    <

     

    Setter.Value>

    <

     

    ControlTemplate>

    <

     

    CheckBox HorizontalAlignment="Center" VerticalAlignment="Center"

    IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}"/>

     

    </

     

    ControlTemplate>

    </Setter.Value>

    </Setter>

     

    </

     

    Style >

    </

     

    ig:FieldSettings.CellValuePresenterStyle

    </

     

    ig:FieldSettings>

    </ig:Field.Settings>

    </ig:Field>

     

     

  • 70
    Verified Answer
    Offline posted

    Found the answer with the help of Support chat

    in the form/usercontrol constructor I had to register value changed event.

    EventManager.RegisterClassHandler(typeof(XamCheckEditor), XamCheckEditor.ValueChangedEvent, new RoutedPropertyChangedEventHandler<object>(xamDataGridCheckChanged));

    and define the event handler to force update by calling EndEditMode

    void xamDataGridCheckChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
            {
                if (sender is XamCheckEditor)
                {
                    ((XamCheckEditor)sender).EndEditMode(true, true);
                }
            }