Hello all,
I have this style in my grid as follows:
<Style TargetType="{x:Type igDP:CellValuePresenter}" BasedOn="{StaticResource {x:Type igDP:CellValuePresenter}}" >
<Setter Property="Background" Value="{Binding ., Converter={StaticResource StateToBackgroundBrushValueConverter}}" >
</Style>
I am trying to bind to the actual cell that is being styled, but using the above approach, it gives me the Record that the cell belongs to instead, which strikes me as odd. How can I get hold of the cell?
Thanks
Hello,
This is because the DataContext of the CellValuePresenter is the DataRecord itself. What you could do is modify the binding so that the path property points to the Value and you need to set the RelativeSource to Self. Another way would be to set the path to DataItem.PropertyName or Cells[X].Value where X is either the index of the field or the name of the field.
Thanks.
What I'm aiming to do though is have my converter return a colour based on not only the data item, but also the field in which the cell lives under.
Is there anything I can bind to which would have a reference to both?
Edit: Looks like the CellValuePresenter does have references to both, can't test at the moment though.