I want to set (e.g.) FontSize for all Hyperlinks in my window. This is my MainWindow's XAML content:
<Window.Resources>
<Style TargetType="{x:Type Hyperlink}">
<EventSetter Event="Click" Handler="Hyperlink_OnClick"/>
<Setter Property="FontSize" Value="30"></Setter>
</Style>
</Window.Resources>
<Grid>
<RichTextBox>
<FlowDocument>
<Paragraph>
something
<Hyperlink>
<Hyperlink.Inlines>
clickable
</Hyperlink.Inlines>
</Hyperlink> ...
</Paragraph>
</FlowDocument>
</RichTextBox>
</Grid>
If I add the style explicitly it works... (i.e. add x:Key="HyperlinkStyle" to the Style tag, and add Style="HyperlinkStyle" to the Hyperlink)
How can I set the style automatically to all Hyperlinks ?
Edit:
@keyboardP, @Anatoliy and @kmatyaszek - you're all right... Thanks to you all! I finally moved the Style tag to the <RichTextBox.Resources> property.
You should set
OverridesDefaultStyleto true:or you can move
Hyperlinkstyle fromWindowresources toRichTextBoxresources.