summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WP8/SliderRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.WP8/SliderRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.WP8/SliderRenderer.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WP8/SliderRenderer.cs b/Xamarin.Forms.Platform.WP8/SliderRenderer.cs
new file mode 100644
index 00000000..40cd767d
--- /dev/null
+++ b/Xamarin.Forms.Platform.WP8/SliderRenderer.cs
@@ -0,0 +1,43 @@
+´╗┐using System.ComponentModel;
+using System.Windows;
+
+namespace Xamarin.Forms.Platform.WinPhone
+{
+ public class SliderRenderer : ViewRenderer<Slider, System.Windows.Controls.Slider>
+ {
+ protected override void OnElementChanged(ElementChangedEventArgs<Slider> e)
+ {
+ base.OnElementChanged(e);
+
+ var wSlider = new System.Windows.Controls.Slider { Minimum = Element.Minimum, Maximum = Element.Maximum, Value = Element.Value };
+
+ SetNativeControl(wSlider);
+
+ wSlider.ValueChanged += HandleValueChanged;
+ }
+
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ base.OnElementPropertyChanged(sender, e);
+
+ switch (e.PropertyName)
+ {
+ case "Minimum":
+ Control.Minimum = Element.Minimum;
+ break;
+ case "Maximum":
+ Control.Maximum = Element.Maximum;
+ break;
+ case "Value":
+ if (Control.Value != Element.Value)
+ Control.Value = Element.Value;
+ break;
+ }
+ }
+
+ void HandleValueChanged(object sender, RoutedPropertyChangedEventArgs<double> routedPropertyChangedEventArgs)
+ {
+ ((IElementController)Element).SetValueFromRenderer(Slider.ValueProperty, Control.Value);
+ }
+ }
+} \ No newline at end of file