diff --git a/MauiProgram.cs b/MauiProgram.cs index 5aaf904..e2dc03f 100644 --- a/MauiProgram.cs +++ b/MauiProgram.cs @@ -1,5 +1,9 @@ using Microsoft.Extensions.Logging; +#if WINDOWS +using CommanderApp.Platforms.Windows.Handlers; +#endif + namespace CommanderApp { public static class MauiProgram @@ -17,6 +21,13 @@ namespace CommanderApp #if DEBUG builder.Logging.AddDebug(); +#endif +#if WINDOWS + // Регистрируем кастомный handler для кнопок + builder.ConfigureMauiHandlers(handlers => + { + handlers.AddHandler(); + }); #endif builder.Services.AddSingleton(); return builder.Build(); diff --git a/Platforms/Windows/CustomButtonHandler.cs b/Platforms/Windows/CustomButtonHandler.cs new file mode 100644 index 0000000..2da6c81 --- /dev/null +++ b/Platforms/Windows/CustomButtonHandler.cs @@ -0,0 +1,64 @@ +#if WINDOWS +using Microsoft.Maui.Handlers; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Markup; + +namespace CommanderApp.Platforms.Windows.Handlers +{ + public partial class CustomButtonHandler : ButtonHandler + { + protected override void ConnectHandler(Microsoft.UI.Xaml.Controls.Button platformView) + { + base.ConnectHandler(platformView); + ConfigureButton(platformView); + } + + private static void ConfigureButton(Microsoft.UI.Xaml.Controls.Button button) + { + // Полностью отключаем все системные визуалы + button.UseSystemFocusVisuals = false; + + var transparentBrush = new Microsoft.UI.Xaml.Media.SolidColorBrush(Microsoft.UI.Colors.Transparent); + + button.FocusVisualPrimaryBrush = transparentBrush; + button.FocusVisualSecondaryBrush = transparentBrush; + button.FocusVisualPrimaryThickness = new Microsoft.UI.Xaml.Thickness(0); + button.FocusVisualSecondaryThickness = new Microsoft.UI.Xaml.Thickness(0); + + button.AllowFocusOnInteraction = true; + button.IsTabStop = true; + + // Отключаем переходы + button.Transitions = null; + + // Создаем минимальный Template + button.Template = CreateMinimalTemplate(); + } + + private static Microsoft.UI.Xaml.Controls.ControlTemplate CreateMinimalTemplate() + { + // Минимальный ControlTemplate без VisualStateManager + var xaml = @" + + + + +"; + + return (Microsoft.UI.Xaml.Controls.ControlTemplate)XamlReader.Load(xaml); + } + } +} +#endif \ No newline at end of file