I have below code in my view (XAML)
<Page
x:Class="MyProject1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
mc:Ignorable="d" Background="Black">
<Grid Background="White" Name="mainGrid">
<Border BorderBrush="Cyan" BorderThickness="0.2" Margin="3,0,3,3">
<ListView x:Name="ListView" VerticalAlignment="Bottom" SelectionMode="None" IsItemClickEnabled="True">
<ListView.ItemTemplate>
<DataTemplate>
<controls:MarkdownTextBlock Name="markdownBlock" Text="[link](www.google.com)">
</controls:MarkdownTextBlock>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Border>
</Grid>
</Page>
I am trying to render hyperlinks in MarkdownTextBlock
control, however when I click on hyperlink, there is no effect.
Same code when I run in browser, works fine.. I mean, I can click on the link and then the new tab/browser opens up for the http request.
What am i missing in my MarkdownTextBlock
control in above xaml code?
Do I need to add any property for the link click to be enabled?
You need to handle the link cliecked event manually where you can launch the browser to the clicked link.
View.xaml
<controls:MarkdownTextBlock Name="markdownBlock" Text="[link](www.google.com)" LinkClicked="MarkdownText_LinkClicked">
View.xaml.cs
private async void MarkdownText_LinkClicked(object sender, UI.Controls.LinkClickedEventArgs e)
{
await Launcher.LaunchUriAsync(new Uri(e.Link));
}