From f7ad317c6734bfdd362ab845b5d9fc8342818171 Mon Sep 17 00:00:00 2001 From: Stepan Pilipenko Date: Fri, 21 Nov 2025 20:11:32 +0300 Subject: [PATCH] button+ --- MainPage.xaml.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/MainPage.xaml.cs b/MainPage.xaml.cs index 7669edc..e579eb0 100644 --- a/MainPage.xaml.cs +++ b/MainPage.xaml.cs @@ -327,6 +327,29 @@ public partial class MainPage : ContentPage, INotifyPropertyChanged CornerRadius = 0 }; + // Устанавливаем тематический цвет текста + // button.SetAppThemeColor(Button.TextColorProperty, Colors.Black, Colors.White); + + // Визуальные состояния для фокуса + var visualStateGroups = new VisualStateGroupList(); + var commonStates = new VisualStateGroup { Name = "CommonStates" }; + + var normalState = new VisualState { Name = "Normal" }; + normalState.Setters.Add(new Setter { Property = Button.BackgroundColorProperty, Value = NormalButtonColor }); + + var focusedState = new VisualState { Name = "Focused" }; + focusedState.Setters.Add(new Setter { Property = Button.BackgroundColorProperty, Value = FocusedButtonColor }); + + var pressedState = new VisualState { Name = "Pressed" }; + pressedState.Setters.Add(new Setter { Property = Button.BackgroundColorProperty, Value = NormalButtonColor }); + + commonStates.States.Add(normalState); + commonStates.States.Add(focusedState); + commonStates.States.Add(pressedState); + visualStateGroups.Add(commonStates); + + VisualStateManager.SetVisualStateGroups(button, visualStateGroups); + // Обработчик клика - выделение при клике, открытие при двойном клике button.Clicked += (s, e) => HandleItemClick(button, item, isLeft);