I have this xaml
<Button.Content>
<Hyperlink>
<Hyperlink.TextDecorations>
<TextDecoration>
<TextDecoration.Pen>
<Pen Thickness="0" />
</TextDecoration.Pen>
</TextDecoration>
</Hyperlink.TextDecorations>
<Run Text="jumped over" />
</Hyperlink>
</Button.Content>
I need to apply this from a style. My style looks like this
<Style x:Key="Button_Link" TargetType="{x:Type Hyperlink}">
<Setter Property="TextDecorations" >
<Setter.Value>
<TextDecorations>
<TextDecoration>
<TextDecoration.Pen>
<Pen Thickness="0" />
</TextDecoration.Pen>
</TextDecoration>
</TextDecorations>
</Setter.Value>
</Setter>
</Style>
This is causing an error in my style file which is a ResourceDictionary used for loose XAML
I am applying the style to Hyperlink like this
Style="{DynamicResource Button_Link}"
You don’t need to set the pen thickness to zero to remove the underline you can using the following style:
In case this is just a simplified example, you can fix your existing style by replacing
<TextDecorations>with<TextDecorationsCollection>like so:Also, although not needed, your style is static so can be applied like