我有一个按钮定义如下:
<Button x:Name="ContactLink" Canvas.Left="20" Canvas.Top="223" Style="{StaticResource HyperlinkButton}" Click="ContactLink_Clicked">
<WrapPanel>
<Rectangle Width="15" Height="15">
<Rectangle.Fill>
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_new_window}" />
</Rectangle.Fill>
</Rectangle>
<TextBlock Margin="5 0 0 0" FontWeight="SemiBold" Text="GET IN TOUCH" />
</WrapPanel>
</Button>
正如标题所说,我想定义一种改变 TextBlock 和 VisualBrush 前景的样式。到目前为止,我有以下风格,这是行不通的。它改变了文本块的前景和 BlackBrush 资源的定义。
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ControlTemplate x:Key="HyperlinkButtonTemplate" TargetType="{x:Type Button}">
<WrapPanel>
<TextBlock Cursor="Hand">
<ContentPresenter />
</TextBlock>
</WrapPanel>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsMouseOver" Value="True">
<Setter Property="TextBlock.Foreground" Value="#0071bc" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="HyperlinkButton" TargetType="{x:Type Button}">
<Setter Property="Template" Value="{StaticResource HyperlinkButtonTemplate}" />
</Style>
</ResourceDictionary>
任何关于让它工作的帮助将不胜感激。