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
90
CellValuePresenter control template that acceses other values of bound data item
posted
I would like to make a cell value presenter control template that displays an icon depending on one value of the bound data item and some text from another property of the bound data item. I know to bind to the content of the field associated with the cellvaluepresenter I can use...

<TextBlock Width="Auto" Height="Auto" Text="{TemplateBinding Content}" TextWrapping="Wrap" HorizontalAlignment="Center" Margin="5,0,0,0" VerticalAlignment="Center" Foreground="#FF000000" x:Name="textBlock"/>

How can I bind to another field/property for the data item? Should I bind to something on the TemplatedParent or is this just impossible?

Thanks! I've provided my full control template below....

 

<Style x:Key="UnitTypeFieldCellImages" TargetType="{x:Type igDP:CellValuePresenter}">

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

<StackPanel x:Name="stackPanel" Orientation="Horizontal">

<Grid Margin="5,0,0,0" x:Name="grid" Width="32" Height="32">

<Grid Width="32" Height="32" x:Name="policecarimage" Visibility="Visible" HorizontalAlignment="Left" VerticalAlignment="Top">

<!--<Image Source="images/policecar_32.png" Height="32" Width="32" />-->

<Image Source="{StaticResource CopCarIcon}" Height="32" Width="32" />

</Grid>

<Image x:Name="firetruckimage" Source="{StaticResource FireTruckIcon}" Height="32" Width="32" Visibility="Hidden" />

</Grid>

<TextBlock Width="Auto" Height="Auto" Text="{TemplateBinding Content}" TextWrapping="Wrap" HorizontalAlignment="Center" Margin="5,0,0,0" VerticalAlignment="Center" Foreground="#FF000000" x:Name="textBlock"/>

</StackPanel>

<ControlTemplate.Triggers>

<Trigger Property="Content" Value="FD">

<Setter Property="Visibility" TargetName="policecarimage" Value="Hidden"/>

<Setter Property="Visibility" TargetName="firetruckimage" Value="Visible"/>

</Trigger>

</ControlTemplate.Triggers>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>