I have a custom UI element inside a CellTempate (VsInputControlNumeric). I want to set this element's IcFontColor property using a trigger when it's row is selected.
<DataGridTemplateColumn Header="{x:Static lp:LanguagePack._Threshold}" IsReadOnly="False" Width="Auto" MinWidth="100" SortMemberPath="Threshold.NumericValue">
<DataGridTemplateColumn.CellStyle>
<Style TargetType="DataGridCell" BasedOn="{StaticResource DataGridCellLeftText}">
<Setter Property="Focusable" Value="True"/>
<Setter Property="Background" Value="{Binding Path=BackColor}"/>
</Style>
</DataGridTemplateColumn.CellStyle>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<view:VsInputControlNumeric
IcControlType="{x:Static configurator:VisualElementType.Numeric}"
IsEnabled="False"
IcFontColor="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=DataContext.FontColor, UpdateSourceTrigger=PropertyChanged, FallbackValue=Black}"
IcBindingValue="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=DataContext.Threshold.RawValue, UpdateSourceTrigger=PropertyChanged, FallbackValue={x:Null}}"
IcTextValue="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=DataContext.Threshold.StringValue, UpdateSourceTrigger=PropertyChanged, FallbackValue={x:Null}}"
HorizontalContentAlignment="Right" ControlHeight="25" BorderThickness="1" Background="{Binding Path=BackColor}"
>
</view:VsInputControlNumeric>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
How could I accomplish this? (Currently I set it from the ViewModel)
Much thanks in advance...
Confusingly enough you can bind to a DataGridRow property using a DataTrigger and not a (property)Trigger. The solution that worked ended up being the following: