diff options
author | Paul DiPietro <pauldipietro@users.noreply.github.com> | 2017-01-03 05:31:48 -0600 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2017-01-03 11:31:48 +0000 |
commit | 6fc18e058bc5bf7eb645fcd91ffdaf6974dfb375 (patch) | |
tree | 42ada310d95ef38d49a459bcde7e330d6c392617 /Xamarin.Forms.Platform.WinRT | |
parent | cc0eb5ba4326de96a52c0318a61b89c3bcb098e5 (diff) | |
download | xamarin-forms-6fc18e058bc5bf7eb645fcd91ffdaf6974dfb375.tar.gz xamarin-forms-6fc18e058bc5bf7eb645fcd91ffdaf6974dfb375.tar.bz2 xamarin-forms-6fc18e058bc5bf7eb645fcd91ffdaf6974dfb375.zip |
[WinRT/UWP] Apply BackgroundColor to Stepper buttons (#581)
* [WinRT/UWP] Apply BackgroundColor to Stepper buttons
* Add explanatory text; use nameof
* Move explanatory text to a label
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) |