summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.UAP
diff options
context:
space:
mode:
authorPaul DiPietro <pauldipietro@users.noreply.github.com>2017-01-03 11:31:48 (GMT)
committerRui Marinho <me@ruimarinho.net>2017-01-03 11:31:48 (GMT)
commit6fc18e058bc5bf7eb645fcd91ffdaf6974dfb375 (patch)
tree42ada310d95ef38d49a459bcde7e330d6c392617 /Xamarin.Forms.Platform.UAP
parentcc0eb5ba4326de96a52c0318a61b89c3bcb098e5 (diff)
downloadxamarin-forms-6fc18e058bc5bf7eb645fcd91ffdaf6974dfb375.zip
xamarin-forms-6fc18e058bc5bf7eb645fcd91ffdaf6974dfb375.tar.gz
xamarin-forms-6fc18e058bc5bf7eb645fcd91ffdaf6974dfb375.tar.bz2
[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.UAP')
-rw-r--r--Xamarin.Forms.Platform.UAP/StepperControl.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.UAP/StepperControl.cs b/Xamarin.Forms.Platform.UAP/StepperControl.cs
index 0de0931..6cf4108 100644
--- a/Xamarin.Forms.Platform.UAP/StepperControl.cs
+++ b/Xamarin.Forms.Platform.UAP/StepperControl.cs
@@ -18,6 +18,8 @@ namespace Xamarin.Forms.Platform.UWP
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));
+
Windows.UI.Xaml.Controls.Button _plus;
Windows.UI.Xaml.Controls.Button _minus;
VisualStateCache _plusStateCache;
@@ -52,6 +54,12 @@ namespace Xamarin.Forms.Platform.UWP
set { SetValue(ValueProperty, value); }
}
+ public Color ButtonBackgroundColor
+ {
+ get { return (Color)GetValue(ButtonBackgroundColorProperty); }
+ set { SetValue(ButtonBackgroundColorProperty, value); }
+ }
+
public event EventHandler ValueChanged;
protected override void OnApplyTemplate()
@@ -67,6 +75,13 @@ namespace Xamarin.Forms.Platform.UWP
_minus.Click += OnMinusClicked;
UpdateEnabled(Value);
+ UpdateButtonBackgroundColor(ButtonBackgroundColor);
+ }
+
+ static void OnButtonBackgroundColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var stepper = (StepperControl)d;
+ stepper.UpdateButtonBackgroundColor(stepper.ButtonBackgroundColor);
}
static void OnIncrementChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
@@ -189,6 +204,17 @@ namespace Xamarin.Forms.Platform.UWP
cache = null;
}
+ void UpdateButtonBackgroundColor(Color value)
+ {
+ Brush brush = value.ToBrush();
+ _minus = GetTemplateChild("Minus") as Windows.UI.Xaml.Controls.Button;
+ _plus = GetTemplateChild("Plus") as Windows.UI.Xaml.Controls.Button;
+ if (_minus != null)
+ _minus.Background = brush;
+ if (_plus != null)
+ _plus.Background = brush;
+ }
+
void UpdateEnabled(double value)
{
double increment = Increment;