Вот определение:
Код: Выделить всё
public partial class EntryChoices : ContentView
{
public static readonly BindableProperty ValuesProperty =
BindableProperty.Create(nameof(Values),
typeof(List), typeof(EntryChoices),
null, BindingMode.TwoWay);
public List? Values
{
get => (List)GetValue(ValuesProperty);
set => SetValue(ValuesProperty, value);
}
}
Код: Выделить всё
Код: Выделить всё
OnPropertyChanged(nameof(Values));
Код: Выделить всё
public void AddItem(string item)
{
if (Values == null)
Values = new List();
Values.Add(item);
OnPropertyChanged(nameof(Values));
OnPropertyChanged(nameof(ValueString));
}
Обновить : теперь значения являются ObservableCollection:
Код: Выделить всё
public static readonly BindableProperty ValuesProperty =
BindableProperty.Create(nameof(Values),
typeof(IEnumerable), typeof(EntryChoices),
defaultBindingMode: BindingMode.TwoWay,
propertyChanged: OnValueChanged);
public ObservableCollection? Values
{
get => (ObservableCollection)GetValue(ValuesProperty);
set => SetValue(ValuesProperty, value);
}
Код: Выделить всё
Код: Выделить всё
[ObservableProperty]
private ObservableCollection _originalList;
Код: Выделить всё
OriginalList = new ObservableCollection(vl);
Подробнее здесь: https://stackoverflow.com/questions/790 ... t-for-maui
Мобильная версия