views:

603

answers:

2

Hi, I'm using an Telerik RadGridView in a WPF application, which has two editable columns - Quantity and Cost. I have created a model for displaying this data in the grid.

e.g ::

 [HasSelfValidation]
 class Item
 {
     public int Quantity{get;set;}
     public decimal Cost{get;set;}

     [SelfValidation]
      public void ValidateQuanity_Cost(...)
      {
         // if Quanity>0, Cost should also be greater than 0.
      }
  }

  public ObservableCollection<Item> Items{get;set;}

  <telerik:RadGridView ItemSource={Binding Items}.../>

I bind an ObservableCollection of the type Item to the telerik GridView. Although the validation works perfectly, I want to highlight the row which generates an error and also display a tooltip. Can anyone help to achieve this?

A: 

You can make your Item expose a BackgroundColor (of type Color) and ToolTipText (of type string) attribute that you can bind to in your data template.

klausbyskov
A: 

Make your Item object expose a “IsValid” property then use a custom type converter to convert it into the background colour. Likewise for the tooltip, but that may need an ErrorType property that is a enum.

Ian Ringrose