diff options
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT')
-rw-r--r-- | Xamarin.Forms.Platform.WinRT/StepperControl.xaml.cs | 21 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.WinRT/StepperRenderer.cs | 8 |
2 files changed, 29 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/StepperControl.xaml.cs b/Xamarin.Forms.Platform.WinRT/StepperControl.xaml.cs index 49a4632f..bf83bf1d 100644 --- a/Xamarin.Forms.Platform.WinRT/StepperControl.xaml.cs +++ b/Xamarin.Forms.Platform.WinRT/StepperControl.xaml.cs @@ -15,6 +15,8 @@ namespace Xamarin.Forms.Platform.WinRT public static readonly DependencyProperty IncrementProperty = DependencyProperty.Register("Increment", typeof(double), typeof(StepperControl), new PropertyMetadata(default(double), OnIncrementChanged)); + public static readonly DependencyProperty ButtonBackgroundColorProperty = DependencyProperty.Register(nameof(ButtonBackgroundColor), typeof(Color), typeof(StepperControl), new PropertyMetadata(default(Color), OnButtonBackgroundColorChanged)); + public StepperControl() { InitializeComponent(); @@ -44,8 +46,20 @@ namespace Xamarin.Forms.Platform.WinRT set { SetValue(ValueProperty, value); } } + public Color ButtonBackgroundColor + { + get { return (Color)GetValue(ButtonBackgroundColorProperty); } + set { SetValue(ButtonBackgroundColorProperty, value); } + } + public event EventHandler ValueChanged; + static void OnButtonBackgroundColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var stepper = (StepperControl)d; + stepper.UpdateButtonBackgroundColor(stepper.ButtonBackgroundColor); + } + static void OnIncrementChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var stepper = (StepperControl)d; @@ -78,6 +92,13 @@ namespace Xamarin.Forms.Platform.WinRT changed(d, EventArgs.Empty); } + void UpdateButtonBackgroundColor(Color value) + { + Windows.UI.Xaml.Media.Brush brush = value.ToBrush(); + Minus.Background = brush; + Plus.Background = brush; + } + void UpdateEnabled(double value) { double increment = Increment; diff --git a/Xamarin.Forms.Platform.WinRT/StepperRenderer.cs b/Xamarin.Forms.Platform.WinRT/StepperRenderer.cs index 7a4724cf..4f09b126 100644 --- a/Xamarin.Forms.Platform.WinRT/StepperRenderer.cs +++ b/Xamarin.Forms.Platform.WinRT/StepperRenderer.cs @@ -42,6 +42,14 @@ namespace Xamarin.Forms.Platform.WinRT UpdateMinimum(); else if (e.PropertyName == Stepper.IncrementProperty.PropertyName) UpdateIncrement(); + else if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName) + UpdateBackgroundColor(); + } + + protected override void UpdateBackgroundColor() + { + if (Control != null) + Control.ButtonBackgroundColor = Element.BackgroundColor; } void OnControlValue(object sender, EventArgs e) |