Hello,
and now I want it only for one label for a specific label.
You can create a custom label that extend the Label
.
public class MyLabel : Label
{
}
Then use this MyLabel
in your xaml layout. and you need local namespace like following code.
<ContentPage
x:Class="MauiFullScreenDemo.MainPage"
//you need add the local name space
xmlns:local="clr-namespace:MauiFullScreenDemo" >
<local:MyLabel Text="this is a text"></local:MyLabel>
In the end, you can set the handler when the label is MyLabel
.
Microsoft.Maui.Handlers.LabelHandler.Mapper.AppendToMapping("MyCustomization", (handler, view) =>
{
if (view is MyLabel)
{
#if ANDROID
handler.PlatformView.SetTextIsSelectable(true);
#endif
}
});
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.