I want to set background of "Name2" to gray because the value is "2".
How can I achieve this?
I tried using DataTrigger with a converter on "PropertyItem" but I had no luck.
You could define an EditorTemplate
for the Name2
property:
<xctk:PropertyGrid ...>
<xctk:PropertyGrid.EditorDefinitions>
<xctk:EditorDefinition>
<xctk:EditorDefinition.PropertiesDefinitions>
<xctk:PropertyDefinition Name="Name2" />
</xctk:EditorDefinition.PropertiesDefinitions>
<xctk:EditorDefinition.EditorTemplate>
<DataTemplate>
<TextBlock Text="{Binding Value}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding Value}" Value="2">
<Setter Property="Background" Value="Gray" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</DataTemplate>
</xctk:EditorDefinition.EditorTemplate>
</xctk:EditorDefinition>
</xctk:PropertyGrid.EditorDefinitions>
</xctk:PropertyGrid>