summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/TemplatedPage.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Core/TemplatedPage.cs')
-rw-r--r--Xamarin.Forms.Core/TemplatedPage.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core/TemplatedPage.cs b/Xamarin.Forms.Core/TemplatedPage.cs
new file mode 100644
index 00000000..69c2d58b
--- /dev/null
+++ b/Xamarin.Forms.Core/TemplatedPage.cs
@@ -0,0 +1,38 @@
+using System.Collections.Generic;
+
+namespace Xamarin.Forms
+{
+ public class TemplatedPage : Page, IControlTemplated
+ {
+ public static readonly BindableProperty ControlTemplateProperty = BindableProperty.Create(nameof(ControlTemplate), typeof(ControlTemplate), typeof(TemplatedPage), null,
+ propertyChanged: TemplateUtilities.OnControlTemplateChanged);
+
+ public ControlTemplate ControlTemplate
+ {
+ get { return (ControlTemplate)GetValue(ControlTemplateProperty); }
+ set { SetValue(ControlTemplateProperty, value); }
+ }
+
+ IList<Element> IControlTemplated.InternalChildren => InternalChildren;
+
+ internal override void ComputeConstraintForView(View view)
+ {
+ LayoutOptions vOptions = view.VerticalOptions;
+ LayoutOptions hOptions = view.HorizontalOptions;
+
+ var result = LayoutConstraint.None;
+ if (vOptions.Alignment == LayoutAlignment.Fill)
+ result |= LayoutConstraint.VerticallyFixed;
+ if (hOptions.Alignment == LayoutAlignment.Fill)
+ result |= LayoutConstraint.HorizontallyFixed;
+
+ view.ComputedConstraint = result;
+ }
+
+ internal override void SetChildInheritedBindingContext(Element child, object context)
+ {
+ if (ControlTemplate == null)
+ base.SetChildInheritedBindingContext(child, context);
+ }
+ }
+} \ No newline at end of file