You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.3 KiB
51 lines
1.3 KiB
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;
|
|
}
|
|
} |