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
360
How to get a cells CellValuePresenter ?
posted

I want to change the background of certain cells in response to data value changes of other cells. So i hook the DataValueChanged and ...

private void xamDataGrid1_DataValueChanged(object sender, DataValueChangedEventArgs e)
{
    var recordPresenter = e.Record;
    var record = e.Record.DataItem as MyObject;
    if (record == null) return;

    if (record.TargetValue != record.ActualValue)
    {
        //i can change the background of the originating cell
        e.CellValuePresenter.Background = Brushes.LightSalmon;
        // but i want to change the other cell as well...
        var cell = recordPresenter.Cells["TargetValue"];
        // HOW DO I GET THE CellValuePresenter OF THIS CELL??
    }
}

Parents
No Data
Reply
  • 138253
    Verified Answer
    Offline posted

    Hello Martin,

     

    Thank you for your post. I have been looking into it and I can suggest you use the CellValuePresenter’s FromCell static method in order to get the CellValuePresenter from a certain Cell like this:

     

    CellValuePresenter cvp = CellValuePresenter.FromCell(cell);

     

    Please let me know if this helps you or you need further assistance on this matter.

     

    Looking forward for your reply.

Children
No Data