|
|
|
|
@ -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 = @"
|
|
|
|
|
<ControlTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
|
|
|
|
|
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
|
|
|
|
|
TargetType='Button'>
|
|
|
|
|
<Grid x:Name='RootGrid'
|
|
|
|
|
Background='{TemplateBinding Background}'
|
|
|
|
|
BorderBrush='{TemplateBinding BorderBrush}'
|
|
|
|
|
BorderThickness='{TemplateBinding BorderThickness}'>
|
|
|
|
|
<ContentPresenter
|
|
|
|
|
x:Name='ContentPresenter'
|
|
|
|
|
Content='{TemplateBinding Content}'
|
|
|
|
|
ContentTemplate='{TemplateBinding ContentTemplate}'
|
|
|
|
|
Margin='{TemplateBinding Padding}'
|
|
|
|
|
HorizontalAlignment='{TemplateBinding HorizontalContentAlignment}'
|
|
|
|
|
VerticalAlignment='{TemplateBinding VerticalContentAlignment}'/>
|
|
|
|
|
</Grid>
|
|
|
|
|
</ControlTemplate>";
|
|
|
|
|
|
|
|
|
|
return (Microsoft.UI.Xaml.Controls.ControlTemplate)XamlReader.Load(xaml);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|