Hi, is there a way to change the color of the text highlighting when a RadEntry is focused? Currently, we need this feature for our project.
1 Answer, 1 is accepted
0
Yana
Telerik team
answered on 20 Oct 2023, 09:22 AM
| edited on 23 Oct 2023, 11:56 AM
Hello Nelson,
Text highlighting is platform-specific and comes from the .NET MAUI Entry default styles on different platforms. For example on Windows you would need to add the styles inside Platforms/Windows.App.xaml file.
I came across the other discussion on Entry styles here: Style for disabled RadEntry is not working, so you just need to add the following setter of the SelectionHighlightColor inside the MaskedEntryControlTextBoxStyle style:
A brand new .NET MAUI course was just added to the Virtual Classroom. The training course is developed to help you get started with the Telerik UI for .NET MAUI components and features. It aims to put you in the shoes of an engineer who adds new features to an existing application. You can check it out at https://learn.telerik.com
Thank you for this. Is it possible to apply this style to a specific entry only?
Yana
Telerik team
commented on 23 Oct 2023, 02:32 PM
Hi Nelson,
If you need to apply a different selection highlight color to one RadEntry instance, you can create a custom class which inherits from RadEntry and override its OnHandlerChanged() method. In it you can get a reference to the Windows TextBox through the InputEditor property and assign its SelectionHighlightColor, here is a quick sample:
publicclassMyRadEntry : RadEntry
{
protectedoverridevoidOnHandlerChanged()
{
base.OnHandlerChanged();
// Step 1. Make sure the PlatformView is availableif (this.Handler?.PlatformView is RadMauiEntry nativeEntry)
{
// Step 2. change the desired native-specific properties#if WINDOWS
nativeEntry.Loaded += (s, a) =>
{
Microsoft.UI.Xaml.Controls.TextBox tb = nativeEntry.InputEditor;
tb.SelectionHighlightColor = new Microsoft.UI.Xaml.Media.SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 0, 0));
};
#endif
}
}
}