Код: Выделить всё
public class IsLanguageNullOrEmptyBehavior : Behavior
{
static readonly BindablePropertyKey IsEmptyPropertyKey =
BindableProperty.CreateReadOnly("IsEmpty", typeof(bool),
typeof(IsLanguageNullOrEmptyBehavior), false);
public static readonly BindableProperty IsEmptyProperty =
IsEmptyPropertyKey.BindableProperty;
public bool IsEmpty
{
get { return (bool)GetValue(IsEmptyProperty); }
set { SetValue(IsEmptyProperty, value); }
}
protected override void OnAttachedTo(LanguageDropdown bindable)
{
base.OnAttachedTo(bindable);
bindable.SelectedItemChanged += Bindable_SelectedItemChanged;
}
protected override void OnDetachingFrom(LanguageDropdown bindable)
{
base.OnDetachingFrom(bindable);
bindable.SelectedItemChanged -= Bindable_SelectedItemChanged;
}
private void Bindable_SelectedItemChanged(object? sender, LanguageModel e)
{
if (e is null)
IsEmpty = true;
else
{
if (string.IsNullOrEmpty(e.LanguageName) ||
string.IsNullOrEmpty(e.Abbreviation))
IsEmpty = true;
else
IsEmpty = false;
}
}
}
Итак, я написал этот код:
Код: Выделить всё
Подробнее здесь: https://stackoverflow.com/questions/790 ... ur-in-maui
Мобильная версия