This is a migrated thread and some comments may be shown as answers.

Cell value

2 Answers 155 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jokerwolf
Top achievements
Rank 1
Jokerwolf asked on 13 Aug 2010, 10:33 AM
Hello,
Is it possible to get the cell value in CellStyleSelector.SelectStyle? I'm getting the whole object, that is nested in the row, and need just the particular cell value, cause the object doesn't contain it.

2 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 16 Aug 2010, 04:39 PM
Hello Jokerwolf,

There is no problem to take the value of a cell inside the SelectStyle method. So, if the definition of your method is for example:

class MyStyleSelector : StyleSelector
{
  public override Style SelectStyle(object item, DependencyObject container)
  {        
    Style st = new Style();
    st.TargetType = typeof(GridViewCell);
    Setter backGroundSetter = new Setter();
    backGroundSetter.Property = GridViewCell.BackgroundProperty;
 
    var cell = (GridViewCell)container;
    var obj = (Player)item;
 
  //custom logic implementation.
    ...
  }
}

You can easily get the value as:
var cellValue = cell.Value;
 

Regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jokerwolf
Top achievements
Rank 1
answered on 17 Aug 2010, 06:19 AM
Well, cell.value is null always (can't understand why), but I've solved the problem by using some calculations in StyleSelector. Thanks for your help.
Tags
GridView
Asked by
Jokerwolf
Top achievements
Rank 1
Answers by
Maya
Telerik team
Jokerwolf
Top achievements
Rank 1
Share this question
or