-1

When I do a MAUI.NET application automatically I got some styling. Partially this is done in styles.xaml, but even if I remove it I still have some styling derived from Windows theme. I have found 3 examples:

  • if you focus in entry the there appear a horizontal line at the bottom of it
  • some vertical line appears next to the selected value in picker
  • selected text got a colour of Windows theme in entry and editor

This is kind fruustraing, but I managed to disable the first option by filling Project/Platforms/Windows/App.xaml file in the manner:

<maui:MauiWinUIApplication
    x:Class="Secretly.WinUI.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:maui="using:Microsoft.Maui"
    xmlns:local="using:___.WinUI">  // ___ is a project name
    <maui:MauiWinUIApplication.Resources> // added this line
        <Thickness x:Key="TextControlBorderThemeThickness">0</Thickness> // added this line
        <Thickness x:Key="TextControlBorderThemeThicknessFocused">0</Thickness> // added this line
    </maui:MauiWinUIApplication.Resources> // added this line
</maui:MauiWinUIApplication>

Is that possible to just turn off this on Windows or even on all platforms? I hope Microsoft respect the situation when developer wants to make his/her application unique and manage it by his/her own.

If not - then side question is how to set selected text color in entry and editor controls as well as this weird vertical line in picker next to choosen value?

jaydopartu
  • 63
  • 1
  • 8
  • Please let me know in comments what is wrong with this question... Is is not cleat? Surely this is not a question about opinion like the last time someone had a problem to my post... So what is wrong this time? – jaydopartu Oct 13 '22 at 20:45

1 Answers1

0

you could use handlers like this to set selected text color:

Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping("MyCustomization", (handler, view) =>
    {
#if WINDOWS
       
       
           handler.PlatformView.SelectionHighlightColor=new Microsoft.UI.Xaml.Media.SolidColorBrush( Windows.UI.Color.FromArgb(255, 255, 0, 0));
       
#endif
    });

For more info, please refer to Customize controls with handlers

Liqun Shen-MSFT
  • 3,490
  • 2
  • 3
  • 11