HyperlinkExtensions
The HyperlinkExtensions class allows for a Hyperlink
element to invoke the execute method on a bound ICommand
instance when clicked.
Platform APIs: HyperlinkExtensions
How it works
Using the HyperlinkExtensions
attached properties simply requires you to assign them to a Hyperlink
control in XAML, and bind to an ICommand
instance in a viewmodel. Both {Binding}
and {x:Bind}
modes are supported, and you can freely choose which one to use depending on your scenario. Here is a small example of these attached properties in action:
<!-- Use Hyperlink in a wrapped TextBlock with text either side and ensure it executes a
command when clicked, passing the current data context as the command parameter -->
<TextBlock xmlns:ui="using:Microsoft.Toolkit.Uwp.UI">
<Run>Some leading text with a</Run>
<Hyperlink
ui:HyperlinkExtensions.Command="{Binding HyperlinkClicked}"
ui:HyperlinkExtensions.CommandParameter="{Binding}">hyperlink</Hyperlink>
<Run>in the middle.</Run>
</TextBlock>
Examples
You can find more examples in the unit tests.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for