Home Forums WPF controls Xceed DataGrid for WPF Changing cell checkbox when modifing another cell

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #22946 |

    Hi everyone,

    I’m using the datagrid control for WPF and i need to check/uncheck a Checkbox cell depending on the value of another cell.

    The underlying value of the checkbox it’s not important (when saving i can control the other cell value), but i’m not able (i don’t know how) to change it when modifing the another field.

    I have tried to make a validation rule, so using

    cellValidationContext.Cell.ParentRow.Cells[“TheOtherCellIWantToChange”].Content

    and

    ((DataRowView)cellValidationContext.DataItem).Row[“TheOtherCellIWantToChange”]

    i can access to the visual content and the underlying data respectively.

    But strangely, it only checks/unchecks the cell at the second time the validation rule is validated.

    Any ideas of how to do this?

    Thanks in advance.

    Imported from legacy forums. Posted by antonio (had 4061 views)

    User (Old forums)
    Member
    Post count: 23064

    Changing the Content property only shows results when the row is unselected.
    Take a look at this
    http://forums.xceed.com/forums/ShowPost.aspx?PostID=6997

    This works for me and the values are bound to the ActualContent Property which redraws immidiatly

    Imported from legacy forums. Posted by MiddleTommy (had 336 views)

    User (Old forums)
    Member
    Post count: 23064

    Thank you MiddelTommy, but is there a solution without create an inherited class?

    I have many pages using the control directly so i should have to change so much code. Is there a way to show results within a validation rule using the standard control (like manually unselecting row or something like that)?

    Thank you very much in advance.

    Imported from legacy forums. Posted by antonio (had 438 views)

    User (Old forums)
    Member
    Post count: 23064

    I have found a solution that in which you don’t need to create a derived class.

    I make the binding to “ActualContent” using the “Tag” property, so later you only have to set the Tag property in order to change the content.

    A solution may be:

    // ##########################

    DataCell myDataCell = (DataCell)cellValidationContext.Cell.ParentRow.Cells[“TheNameOfTheColumnToChange”];

    ceb = new Binding(“ActualContent”);
    ceb.Source = myDataCell ;
    ceb.Mode = BindingMode.TwoWay;
    BindingOperations.SetBinding(myDataCell , DataCell.TagProperty, ceb);

    myDataCell .Tag = TheValueIWantToSet;

    // ##########################

    Thank you

    Imported from legacy forums. Posted by antonio (had 345 views)

    User (Old forums)
    Member
    Post count: 23064

    Property Hijacking-
    I am glad this works for you

    Imported from legacy forums. Posted by MiddleTommy (had 289 views)

    User (Old forums)
    Member
    Post count: 23064

    Where do you put this code? Inside the Validate method of a Validator?

    Imported from legacy forums. Posted by curelom (had 5134 views)

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.