This seems as if it should be simple, but I can’t make it happen… I’ve got a datagrid with a template column that includes a button:
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource LinkButton}" Content="{Binding Path=...}"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
and my linkbutton style looks like this:
<Style x:Key="LinkButton" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<ControlTemplate.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="TextDecorations" Value="Underline" />
</Style>
</ControlTemplate.Resources>
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="Blue" />
<Setter Property="Cursor" Value="Hand" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Foreground" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
When the row is selected, I want to change the foreground color of the linkbutton to white or something. Is there an easy way to accomplish this?
Or something like that…
(By the way, what about using the
DataGridHyperlinkColumn, or at the very least just a normalHyperlinkinstead of aButton?)