summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT/LayoutRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT/LayoutRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.WinRT/LayoutRenderer.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/LayoutRenderer.cs b/Xamarin.Forms.Platform.WinRT/LayoutRenderer.cs
new file mode 100644
index 00000000..86748dc8
--- /dev/null
+++ b/Xamarin.Forms.Platform.WinRT/LayoutRenderer.cs
@@ -0,0 +1,55 @@
+´╗┐using System.ComponentModel;
+using Windows.Foundation;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Media;
+
+#if WINDOWS_UWP
+
+namespace Xamarin.Forms.Platform.UWP
+#else
+
+namespace Xamarin.Forms.Platform.WinRT
+#endif
+{
+ public class LayoutRenderer : ViewRenderer<Layout, FrameworkElement>
+ {
+ protected override void OnElementChanged(ElementChangedEventArgs<Layout> e)
+ {
+ base.OnElementChanged(e);
+
+ if (e.OldElement != null)
+ {
+ SizeChanged -= OnSizeChanged;
+ }
+
+ if (e.NewElement != null)
+ {
+ SizeChanged += OnSizeChanged;
+
+ UpdateClipToBounds();
+ }
+ }
+
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ base.OnElementPropertyChanged(sender, e);
+
+ if (e.PropertyName == Layout.IsClippedToBoundsProperty.PropertyName)
+ UpdateClipToBounds();
+ }
+
+ void OnSizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ UpdateClipToBounds();
+ }
+
+ void UpdateClipToBounds()
+ {
+ Clip = null;
+ if (Element.IsClippedToBounds)
+ {
+ Clip = new RectangleGeometry { Rect = new Rect(0, 0, ActualWidth, ActualHeight) };
+ }
+ }
+ }
+} \ No newline at end of file