Clickable TextBlock Inlines #15916
-
Hello all, I'm porting a WPF application over to Avalonia (and have asked a couple of questions already, thank you for the help so far), and have hit another snag: In WPF, I had a little class for styling a In Avalonia, the What is the best way of reproducing this behaviour in Avalonia? Should I use an Any suggestions are greatly appreciated.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
<Window.Styles>
<Style Selector="HyperlinkButton">
<Setter Property="TextBlock.TextDecorations" Value="" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0" />
</Style>
<Style Selector="HyperlinkButton:pointerover">
<Setter Property="TextBlock.TextDecorations" Value="Underline" />
</Style>
</Window.Styles>
<TextBlock>
<Run Text="This has no underline," />
<InlineUIContainer>
<HyperlinkButton Content="but this does when hovered" />
</InlineUIContainer>
<Run Text="and back to not" />
</TextBlock> If you're trying to dynamically highlight, then you need to parse text for URIs yourself and build inlines. |
Beta Was this translation helpful? Give feedback.
-
I prefer using an |
Beta Was this translation helpful? Give feedback.
I prefer using an
InlineUIContainer
and hosting aTextBlock
orButton
inside it. This will allow you to handle pointer events and apply styling as needed.