New to Telerik UI for .NET MAUI? Start a free 30-day trial
Creating a Copyright Label Control in .NET MAUI
Updated on Jun 9, 2025
Environment
| Product | Author |
|---|---|
| .NET MAUI | Dobrinka Yordanova |
Description
I want to know how to create a Copyright label control for my application using .NET MAUI. I need the control to display the copyright symbol followed by a year and some text, with custom text color, underlining, and tap gesture recognizers for handling user interactions.
This knowledge base article also answers the following questions:
- How to format text in a Label using spans in .NET MAUI?
- How to add tap gesture recognizers to a Label in .NET MAUI app?
- How to underline and set text colors for individual spans in .NET MAUI?
Solution
To create a Copyright label control, use the Label control with formatted text consisting of multiple spans. Below is the implementation:
xaml
<Label>
<Label.FormattedText>
<FormattedString>
<!-- Display the copyright symbol -->
<Span Text="©" />
<!-- Display the copyright year and text with custom styling -->
<Span Text="Copyright 2025"
TextColor="Blue"
TextDecorations="Underline">
<!-- Add a tap gesture recognizer -->
<Span.GestureRecognizers>
<TapGestureRecognizer Command="{Binding TapCommand}" />
</Span.GestureRecognizers>
</Span>
</FormattedString>
</Label.FormattedText>
</Label>
- The
SpaninsideFormattedStringallows you to define segments of text with different styles and behaviors. - The copyright symbol (
©) is defined as a separateSpan. - Another
Spanis used for the "Copyright 2025" text, withTextColorset toBlueandTextDecorationsset toUnderline. - A
TapGestureRecognizeris added to the secondSpanto handle user interactions. Bind it to a command in the view model using{Binding TapCommand}.