summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla48236.cs46
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems1
-rw-r--r--Xamarin.Forms.Platform.UAP/StepperControl.cs26
-rw-r--r--Xamarin.Forms.Platform.WinRT/StepperControl.xaml.cs21
-rw-r--r--Xamarin.Forms.Platform.WinRT/StepperRenderer.cs8
5 files changed, 102 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla48236.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla48236.cs
new file mode 100644
index 00000000..322d4fcd
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla48236.cs
@@ -0,0 +1,46 @@
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 48236, "[WinRT/UWP] BackgroundColor for Stepper behaves differently compared to iOS to Android", PlatformAffected.WinRT)]
+ public class Bugzilla48236 : TestContentPage
+ {
+ protected override void Init()
+ {
+ var stepper = new Stepper
+ {
+ BackgroundColor = Color.Green,
+ Minimum = 0,
+ Maximum = 10
+ };
+
+ Content = new StackLayout
+ {
+ Children =
+ {
+ new Label
+ {
+ Text = "If the Stepper's background color extends the width of the page, then this test has failed."
+ },
+ stepper,
+ new Button
+ {
+ BackgroundColor = Color.Aqua,
+ Text = "Change Stepper Color to Yellow",
+ Command = new Command(() =>
+ {
+ stepper.BackgroundColor = Color.Yellow;
+ })
+ }
+ }
+ };
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
index 4820bae3..e0af0ca2 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
@@ -152,6 +152,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla46494.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla44476.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla46630.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla48236.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla47971.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CarouselAsync.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34561.cs" />
diff --git a/Xamarin.Forms.Platform.UAP/StepperControl.cs b/Xamarin.Forms.Platform.UAP/StepperControl.cs
index 0de09318..6cf41086 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;
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)