Introduction
Our phones and computers are like magic doors to the world, thanks to the apps we use every day. These apps show us stuff using a mix of words, pictures, and special links that let us explore more. ๐ Links, especially, make it easy for us to dive deep into things. In this guide, we'll learn how to add these special links to your .NET MAUI apps, making it more fun for people to check out what you have to share. Join us on this enlightening journey as we unravel the secrets of Transforming Labels into Hyperlinks with .NET MAUI.
Project Setup
- Launch Visual Studio 2022, and in the start window click Create a new project to create a new project.
- In the Create a new project window, select MAUI in the All project types drop-down, select the .NET MAUI App template, and click the Next button:
- In the Configure your new project window, name your project, choose a suitable location for it, and click the Next button:
- In the Additional information window, click the Create button:
- Once the project is created, we can able to see the Android, iOS, Windows, and other running options in the toolbar. Press the emulator or run button to build and run the app
Implementation
<HorizontalStackLayout>
<Label
Text="To know more about .NET MAUI "
SemanticProperties.HeadingLevel="Level1"
FontSize="Default"
HorizontalOptions="Center" />
<Label
Text="Visit Here"
TextDecorations="Underline"
TextColor="Blue"
SemanticProperties.HeadingLevel="Level1"
FontSize="Default"
HorizontalOptions="Center" >
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="OnUrlClicked"/>
</Label.GestureRecognizers>
</Label>
</HorizontalStackLayout>
Demo
Download Code
You can download the code from
GitHub. If you have any doubts, feel free to post a comment. If you liked this article, and it is useful to you, do like, share the article & star the repository on
GitHub.