diff options
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen/Renderers/LayoutRenderer.cs')
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/Renderers/LayoutRenderer.cs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/LayoutRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/LayoutRenderer.cs new file mode 100644 index 00000000..61421c79 --- /dev/null +++ b/Xamarin.Forms.Platform.Tizen/Renderers/LayoutRenderer.cs @@ -0,0 +1,57 @@ +using System; + +namespace Xamarin.Forms.Platform.Tizen +{ + /// <summary> + /// Renderer of a Layout. + /// </summary> + public class LayoutRenderer : ViewRenderer<Layout, Native.Canvas> + { + /// <summary> + /// Default constructor. + /// </summary> + public LayoutRenderer() + { + } + + protected override void UpdateLayout() + { + // in case of layouts we need to make sure that the minimum size of the native control is updated + // this is important in case of ScrollView, when it's content is likely to be wider/higher than the window + // EFL does not allow control to be larger than the window if it's minimum size is smaller than window dimensions + ScrollView scrollView = Element.Parent as ScrollView; + if (scrollView != null) + { + Size size = scrollView.ContentSize; + Control.MinimumWidth = ToNativeDimension(Math.Max(size.Width, scrollView.Content.Width)); + Control.MinimumHeight = ToNativeDimension(Math.Max(size.Height, scrollView.Content.Height)); + } + + base.UpdateLayout(); + } + + protected override void OnElementChanged(ElementChangedEventArgs<Layout> e) + { + if (null == Control) + { + var canvas = new Native.Canvas(Forms.Context.MainWindow); + canvas.LayoutUpdated += OnLayoutUpdated; + SetNativeControl(canvas); + } + + base.OnElementChanged(e); + } + + protected override void Dispose(bool disposing) + { + Control.LayoutUpdated -= OnLayoutUpdated; + + base.Dispose(disposing); + } + + void OnLayoutUpdated(object sender, Native.LayoutEventArgs e) + { + DoLayout(e); + } + } +} |