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
1770
undo checkbox value in cell
posted

Hello. I'm having a strange problem where I can't seem to undo the value in a check box field. The field is of type boolean. I'm not sure if this is a xamDataGrid thing or something else. I'm using MVVM and this is what I have:

<xamdatagrid DataSource="{Binding Data, Mode=TwoWay}">

<i:Interaction.Triggers>

<i:EventTrigger EventName="CellChanged">
<command:EventToCommand Command="{Binding OnCellChangedCommand}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>

</xamdatagrid>

private void OnCellChanged(CellChangedEventArgs e)
{

    var createEvent = (bool)e.Editor.Value;

    if(createEvent){//if the new value is true

       if(some logic){ e.Cell.Value = false }

   }

}

So looking at the first if statement. If the user checks an unchecked checkbox in a cell, I check whether he can in fact check that check box. If not, I want the checkbox to return to an unchecked state.

The statement  "e.Cell.Value = false" does not seem to be doing anything. Any ideas?

Parents
No Data
Reply
  • 22015
    posted

    Hello KrisVice,

     

    Thank you for your post!

     

    I have been looking into the code snippet, that you have provided.

    In the code snippet you are assigning the value to the cell - "      if(some logic){ e.Cell.Value = false }". This way the editor would not be changed.

    If you would like to change the value of the editor, I would suggest setting the value as follows: e.Editor.Value = false.

     

    Please do not hesitate to let me know if you have any further questions on this matter.

Children