namespace ShoopNCook.Views; public partial class CounterView : ContentView { private readonly BindableProperty CountProperty = BindableProperty.Create(nameof(CountLabel), typeof(uint), typeof(CounterView), default(uint) + 1); private readonly BindableProperty CounterLabelProperty = BindableProperty.Create(nameof(CounterLabel), typeof(string), typeof(CounterView), default(string)); public CounterView() { InitializeComponent(); CountLabel.BindingContext = this; CountLabel.SetBinding(Label.TextProperty, nameof(Count)); CounterLabel.BindingContext = this; CounterLabel.SetBinding(Label.TextProperty, nameof(CounterText)); } public uint Count { get => (uint)GetValue(CountProperty); set { SetValue(CountProperty, value <= 1 ? 1 : uint.Parse(value.ToString())); OnPropertyChanged(nameof(Count)); } } public string CounterText { get => (string)GetValue(CounterLabelProperty); set { SetValue(CounterLabelProperty, value); OnPropertyChanged(nameof(CounterText)); } } private void OnPlus(object o, EventArgs e) { Count += 1; } private void OnMinus(object o, EventArgs e) { Count -= 1; } }