summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT/ProgressBarRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT/ProgressBarRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.WinRT/ProgressBarRenderer.cs59
1 files changed, 59 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/ProgressBarRenderer.cs b/Xamarin.Forms.Platform.WinRT/ProgressBarRenderer.cs
new file mode 100644
index 00000000..87f1e35e
--- /dev/null
+++ b/Xamarin.Forms.Platform.WinRT/ProgressBarRenderer.cs
@@ -0,0 +1,59 @@
+´╗┐using System.ComponentModel;
+using Windows.UI.Xaml.Controls.Primitives;
+
+#if WINDOWS_UWP
+
+namespace Xamarin.Forms.Platform.UWP
+#else
+
+namespace Xamarin.Forms.Platform.WinRT
+#endif
+{
+ public class ProgressBarRenderer : ViewRenderer<ProgressBar, Windows.UI.Xaml.Controls.ProgressBar>
+ {
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ if (Control != null)
+ {
+ Control.ValueChanged -= ProgressBarOnValueChanged;
+ }
+ }
+
+ base.Dispose(disposing);
+ }
+
+ protected override void OnElementChanged(ElementChangedEventArgs<ProgressBar> e)
+ {
+ base.OnElementChanged(e);
+
+ if (e.NewElement != null)
+ {
+ if (Control == null)
+ {
+ var progressBar = new Windows.UI.Xaml.Controls.ProgressBar { Minimum = 0, Maximum = 1 };
+
+ progressBar.ValueChanged += ProgressBarOnValueChanged;
+
+ SetNativeControl(progressBar);
+ }
+
+ Control.Value = e.NewElement.Progress;
+ }
+ }
+
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ base.OnElementPropertyChanged(sender, e);
+
+ if (e.PropertyName == ProgressBar.ProgressProperty.PropertyName)
+ Control.Value = Element.Progress;
+ }
+
+ void ProgressBarOnValueChanged(object sender, RangeBaseValueChangedEventArgs rangeBaseValueChangedEventArgs)
+ {
+ Element?.InvalidateMeasure(InvalidationTrigger.MeasureChanged);
+ }
+ }
+} \ No newline at end of file