Можем ли мы добавить визуальные состояния для обычного вида (например, метки) с помощью средства распознавания жестов Tap? - PullRequest
0 голосов
/ 03 февраля 2020

Из-за некоторых сложных требований к пользовательскому интерфейсу мы используем Frame с Tap Gesture в качестве замены Button. Можно ли добавить визуальные состояния («Сосредоточено», «Нажатие», «Отключено») для обычного просмотра?

1 Ответ

1 голос
/ 04 февраля 2020

Вы можете создать пользовательский Frame для добавления пользовательских привязываемых свойств для его реализации. Например, добавить три свойства для CustomFrame. Вы можете добавить другое более настраиваемое свойство, если нужно.

public class CustomFrame :Frame
{
    public static readonly BindableProperty CustomFocusedProperty = BindableProperty.Create("CustomFocused", typeof(bool), typeof(CustomFrame), null);

    public bool CustomFocused
    {
        get { return (bool)GetValue(CustomFocusedProperty); }
        set { SetValue(CustomFocusedProperty, value); }
    }


    public static readonly BindableProperty CustomClickedProperty = BindableProperty.Create("CustomClicked", typeof(bool), typeof(CustomFrame), null);

    public bool CustomClicked
    {
        get { return (bool)GetValue(CustomClickedProperty); }
        set { SetValue(CustomClickedProperty, value); }
    }


    public static readonly BindableProperty CustomDisabledProperty = BindableProperty.Create("DisabledFocused", typeof(bool), typeof(CustomFrame), null);

    public bool DisabledFocused
    {
        get { return (bool)GetValue(CustomDisabledProperty); }
        set { SetValue(CustomDisabledProperty, value); }
    }
}

Uesd в Xaml : <local:CustomFrame x:Name="CustomFrame" />

Затем вы можете установить или получить значение из пользовательского свойства:

CustomFrame.CustomClicked = true;
CustomFrame.CustomFocused = true;
CustomFrame.CustomDisabled = true;
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...