I want to create a number of grids that are bound to objects that have Boolean properties.
I want create a generic style that I can apply to various columns of my choosing that causes a cell to have "tick" if the value is true, but a "cross" if the value is false.
So far I have not been able to accomplish this because the DataContext for the GridViewCell is an entire DataRecord, rather than just the field that I'm binding to that column.
Therefore my DataTrigger requires that I know the FieldName or the FieldPosition in order to retrieve the value; so I have to create a template for each DataObject. E.g.
What I really want is for the Binding to be boudn to whatever value is in the cell being styled. Does anyone know how to acheieve this.
Regards
Justin
- Sorry if this is a little unclear, let me know if you need clarification.
I want create a generic style that I can apply to various columns of my choosing that causes a cell to have "tick" if the value is true, but a "cross" if the value is false.
<Style x:Key="YesNoCellStyle" TargetType="telerik:GridViewCell"> |
<Setter Property="Template"> |
<Setter.Value> |
<ControlTemplate TargetType="telerik:GridViewCell"> |
<Image x:Name="img" Source="Images/tick.png" |
Width="16" Height="16" /> |
<ControlTemplate.Triggers> |
<DataTrigger Binding="{Binding}" Value="False"> |
<Setter TargetName="img" Property="Source" Value="Images/cross.png"/> |
</DataTrigger> |
</ControlTemplate.Triggers> |
</ControlTemplate> |
</Setter.Value> |
</Setter> |
</Style> |
So far I have not been able to accomplish this because the DataContext for the GridViewCell is an entire DataRecord, rather than just the field that I'm binding to that column.
Therefore my DataTrigger requires that I know the FieldName or the FieldPosition in order to retrieve the value; so I have to create a template for each DataObject. E.g.
<DataTrigger Binding="{Binding Path=Data.Type}" Value="False"> |
<DataTrigger Binding="{Binding Path=Data.IsAvailable}" Value="False"> |
<DataTrigger Binding="{Binding Path=Data.IsValid}" Value="False"> |
What I really want is for the Binding to be boudn to whatever value is in the cell being styled. Does anyone know how to acheieve this.
Regards
Justin
- Sorry if this is a little unclear, let me know if you need clarification.