summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT/StepperRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT/StepperRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.WinRT/StepperRenderer.cs72
1 files changed, 72 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/StepperRenderer.cs b/Xamarin.Forms.Platform.WinRT/StepperRenderer.cs
new file mode 100644
index 00000000..7a4724cf
--- /dev/null
+++ b/Xamarin.Forms.Platform.WinRT/StepperRenderer.cs
@@ -0,0 +1,72 @@
+´╗┐using System;
+using System.ComponentModel;
+
+#if WINDOWS_UWP
+
+namespace Xamarin.Forms.Platform.UWP
+#else
+
+namespace Xamarin.Forms.Platform.WinRT
+#endif
+{
+ public class StepperRenderer : ViewRenderer<Stepper, StepperControl>
+ {
+ protected override void OnElementChanged(ElementChangedEventArgs<Stepper> e)
+ {
+ base.OnElementChanged(e);
+
+ if (e.NewElement != null)
+ {
+ if (Control == null)
+ {
+ SetNativeControl(new StepperControl());
+ Control.ValueChanged += OnControlValue;
+ }
+
+ UpdateMaximum();
+ UpdateMinimum();
+ UpdateValue();
+ UpdateIncrement();
+ }
+ }
+
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ base.OnElementPropertyChanged(sender, e);
+
+ if (e.PropertyName == Stepper.ValueProperty.PropertyName)
+ UpdateValue();
+ else if (e.PropertyName == Stepper.MaximumProperty.PropertyName)
+ UpdateMaximum();
+ else if (e.PropertyName == Stepper.MinimumProperty.PropertyName)
+ UpdateMinimum();
+ else if (e.PropertyName == Stepper.IncrementProperty.PropertyName)
+ UpdateIncrement();
+ }
+
+ void OnControlValue(object sender, EventArgs e)
+ {
+ Element.SetValueCore(Stepper.ValueProperty, Control.Value);
+ }
+
+ void UpdateIncrement()
+ {
+ Control.Increment = Element.Increment;
+ }
+
+ void UpdateMaximum()
+ {
+ Control.Maximum = Element.Maximum;
+ }
+
+ void UpdateMinimum()
+ {
+ Control.Minimum = Element.Minimum;
+ }
+
+ void UpdateValue()
+ {
+ Control.Value = Element.Value;
+ }
+ }
+} \ No newline at end of file