}
if (navPage != null) {
- navPage.Navigation.RemovePage ((Page) navPage.InternalChildren[navPage.InternalChildren.Count - 2]);
+ navPage.Navigation.RemovePage ((Page)((IPageController)navPage).InternalChildren[((IPageController)navPage).InternalChildren.Count - 2]);
}
};
contentView.Content = child;
contentView.Platform = platform;
- Assert.AreEqual (child, contentView.LogicalChildren[0]);
+ Assert.AreEqual (child, ((IElementController)contentView).LogicalChildren[0]);
}
class SimpleTemplate : StackLayout
contentView.ControlTemplate = new ControlTemplate (typeof (SimpleTemplate));
contentView.Platform = platform;
- Assert.That (contentView.LogicalChildren[0], Is.TypeOf<SimpleTemplate> ());
+ Assert.That (((IElementController)contentView).LogicalChildren[0], Is.TypeOf<SimpleTemplate> ());
}
[Test]
contentView.Content = child;
contentView.Platform = platform;
- Assume.That (contentView.LogicalChildren[0], Is.TypeOf<SimpleTemplate> ());
+ Assume.That (((IElementController)contentView).LogicalChildren[0], Is.TypeOf<SimpleTemplate> ());
Assert.That (contentView.Descendants (), Contains.Item (child));
}
var bc = "Test";
contentView.BindingContext = bc;
- Assert.AreNotEqual (bc, contentView.LogicalChildren[0].BindingContext);
- Assert.IsNull (contentView.LogicalChildren[0].BindingContext);
+ Assert.AreNotEqual (bc, ((IElementController)contentView).LogicalChildren[0].BindingContext);
+ Assert.IsNull (((IElementController)contentView).LogicalChildren[0].BindingContext);
}
[Test]
var label = new Label ();
testView.Content = label;
- var originalPresenter = (ContentPresenter)testView.LogicalChildren[0].LogicalChildren[0];
+
+ var child1 = ((IElementController)testView).LogicalChildren[0];
+ var child2 = ((IElementController)child1).LogicalChildren[0];
+
+ var originalPresenter = (ContentPresenter)child2;
Assert.AreEqual (label, originalPresenter.Content);
public void NestedTemplateBindings ()
{
var testView = new TestView ();
- var label = (Label)testView.LogicalChildren[0].LogicalChildren[0];
+
+ var child1 = ((IElementController)testView).LogicalChildren[0];
+ var child2 = ((IElementController)child1).LogicalChildren[0];
+
+ var label = (Label)child2;
testView.Platform = new UnitPlatform ();
Assert.IsNull (label.Text);
parentView.Content = childView;
childView.Content = new Button ();
- var childPresenter = (ContentPresenter)childView.LogicalChildren[0].LogicalChildren[1];
+
+ var child1 = ((IElementController)childView).LogicalChildren[0];
+ var child2 = ((IElementController)child1).LogicalChildren[1];
+
+ var childPresenter = (ContentPresenter)child2;
parentView.ControlTemplate = new ControlTemplate (typeof (ContentControl));
Assert.IsNotNull (childPresenter.Content);
page.ControlTemplate = new ControlTemplate (typeof (TestContent));
page.SetBinding (TestPage.NameProperty, "Name");
- var entry = ((ContentView)page.LogicalChildren[0]).Content as Entry;
+ var entry = ((ContentView)((IElementController)page).LogicalChildren[0]).Content as Entry;
((IElementController)entry).SetValueFromRenderer (Entry.TextProperty, "Bar");
viewModel.Name = "Raz";
get { return internalChildren; }
}
- internal override ReadOnlyCollection<Element> LogicalChildren
+ internal override ReadOnlyCollection<Element> LogicalChildrenInternal
{
get { return new ReadOnlyCollection<Element> (internalChildren); }
}
};
layout.Children.Remove (labela0);
- Assert.False (layout.LogicalChildren.Contains (labela0));
+ Assert.False (((IElementController)layout).LogicalChildren.Contains (labela0));
}
[Test]
{
protected override void LayoutChildren (double x, double y, double width, double height)
{
- foreach (var child in LogicalChildren.Cast<View>()) {
+ foreach (var child in ((IElementController)this).LogicalChildren.Cast<View>()) {
var result = new Rectangle (x, y, 0, 0);
var request = child.GetSizeRequest (double.PositiveInfinity, double.PositiveInfinity);
result.Width = request.Request.Width;
view.RaiseChild (child1);
- Assert.AreEqual (child1, view.LogicalChildren [2]);
+ Assert.AreEqual (child1, ((IElementController)view).LogicalChildren [2]);
Assert.True (reordered);
view.RaiseChild (child2);
- Assert.AreEqual (child2, view.LogicalChildren [2]);
+ Assert.AreEqual (child2, ((IElementController)view).LogicalChildren [2]);
}
[Test]
view.LowerChild (child3);
- Assert.AreEqual (child3, view.LogicalChildren [0]);
+ Assert.AreEqual (child3, ((IElementController)view).LogicalChildren [0]);
Assert.True (reordered);
view.LowerChild (child2);
- Assert.AreEqual (child2, view.LogicalChildren [0]);
+ Assert.AreEqual (child2, ((IElementController)view).LogicalChildren [0]);
}
[Test]
view.Children.Add (child1);
Assert.True (added);
- Assert.AreEqual (child1, view.LogicalChildren [0]);
+ Assert.AreEqual (child1, ((IElementController)view).LogicalChildren [0]);
}
[Test]
view.Children.Add (child1);
Assert.False (added);
- Assert.AreEqual (child1, view.LogicalChildren [0]);
+ Assert.AreEqual (child1, ((IElementController)view).LogicalChildren [0]);
}
[Test]
view.Children.Remove (child1);
Assert.True (removed);
- Assert.False (view.LogicalChildren.Any ());
+ Assert.False (((IElementController)view).LogicalChildren.Any ());
}
[Test]
view.Children.Add (child);
int i = 0;
- foreach (var child in view.LogicalChildren) {
+ foreach (var child in ((IElementController)view).LogicalChildren) {
Assert.AreEqual (children[i], child);
i++;
}
view.Children.Add (child);
int i = 0;
- var enumerator = (view.LogicalChildren as IEnumerable).GetEnumerator ();
+ var enumerator = (((IElementController)view).LogicalChildren as IEnumerable).GetEnumerator ();
while (enumerator.MoveNext ()) {
Assert.AreEqual (children [i], enumerator.Current as View);
i++;
}
};
- Assert.AreEqual (2, group.LogicalChildren.Count);
- Assert.IsTrue (group.LogicalChildren.Contains (view1));
- Assert.IsTrue (group.LogicalChildren.Contains (view2));
- Assert.AreEqual (view1, group.LogicalChildren[0]);
+ Assert.AreEqual (2, ((IElementController)group).LogicalChildren.Count);
+ Assert.IsTrue (((IElementController)group).LogicalChildren.Contains (view1));
+ Assert.IsTrue (((IElementController)group).LogicalChildren.Contains (view2));
+ Assert.AreEqual (view1, ((IElementController)group).LogicalChildren[0]);
}
[Test]
container.Children.Add (CreateContainedPage());
Assert.AreEqual (2, childCount);
- Assert.AreEqual (2, page.LogicalChildren.Count);
+ Assert.AreEqual (2, ((IElementController)page).LogicalChildren.Count);
Assert.AreEqual (2, pagesAdded);
}
Assert.AreEqual (2, removeCount);
Assert.AreEqual (2, childCount);
- Assert.AreEqual (2, page.LogicalChildren.Count);
+ Assert.AreEqual (2, ((IElementController)page).LogicalChildren.Count);
}
[Test]
var root = new ContentPage ();
var nav = new NavigationPage (root);
- Assert.AreEqual (root, nav.LogicalChildren[0]);
+
Assert.AreEqual (1, ((INavigationPageController)nav).StackDepth);
+ Assert.AreEqual (root, ((IElementController)nav).LogicalChildren[0]);
+
}
[Test]
new PropertyTestCase<Page, Color> ("BackgroundColor", v => v.BackgroundColor, (v, o) => v.BackgroundColor = o, () => default(Color), new Color (0, 1, 0)),
new PropertyTestCase<Page, string> ("Title", v => v.Title, (v, o) => v.Title = o, () => null, "Foo"),
new PropertyTestCase<Page, bool> ("IsBusy", v => v.IsBusy, (v, o) => v.IsBusy = o, () => false, true),
- new PropertyTestCase<Page, bool> ("IgnoresContainerArea", v => v.IgnoresContainerArea, (v, o) => v.IgnoresContainerArea = o, () => false, true),
+ new PropertyTestCase<Page, bool> ("IgnoresContainerArea", v => ((IPageController)v).IgnoresContainerArea, (v, o) => ((IPageController)v).IgnoresContainerArea = o, () => false, true),
new PropertyTestCase<Page, Thickness> ("Padding", v => v.Padding, (v, o) => v.Padding = o, () => default(Thickness), new Thickness (12)),
new PropertyTestCase<Picker, string> ("Title", v=>v.Title, (v, o) =>v.Title = o, () => null, "FooBar"),
new PropertyTestCase<Picker, int> ("SelectedIndex", v=>v.SelectedIndex, (v, o) =>v.SelectedIndex = o, () => -1, 2, ()=>new Picker{Items= {"Foo", "Bar", "Baz", "Qux"}}),
var child = new Label ();
Page root = new ContentPage {Content = child};
- Assert.AreEqual (root.LogicalChildren.Count, 1);
- Assert.AreSame (root.LogicalChildren.First (), child);
+ Assert.AreEqual (((IElementController)root).LogicalChildren.Count, 1);
+ Assert.AreSame (((IElementController)root).LogicalChildren.First (), child);
}
[Test]
page.Layout (new Rectangle (0, 0, 800, 800));
Assert.AreEqual (new Rectangle (0, 0, 800, 800), child.Bounds);
-
- page.ContainerArea = new Rectangle (10, 10, 30, 30);
+ ((IPageController)page).ContainerArea = new Rectangle (10, 10, 30, 30);
Assert.AreEqual (new Rectangle (10, 10, 30, 30), child.Bounds);
Assert.That (sent, Is.False, "Busy message sent while not visible");
- page.SendAppearing();
+ ((IPageController)page).SendAppearing();
Assert.That (sent, Is.True, "Busy message not sent when visible");
}
public void BusySentWhenBusyPageDisappears()
{
var page = new ContentPage { IsBusy = true };
- page.SendAppearing();
+ ((IPageController)page).SendAppearing();
var sent = false;
MessagingCenter.Subscribe<Page, bool> (this, Page.BusySetSignalName, (p, b) => {
sent = true;
});
- page.SendDisappearing();
+ ((IPageController)page).SendDisappearing();
Assert.That (sent, Is.True, "Busy message not sent when visible");
}
MessagingCenter.Subscribe<Page, bool> (this, Page.BusySetSignalName, (p, b) => sent = true);
var page = new ContentPage();
- page.SendAppearing();
+ ((IPageController)page).SendAppearing();
Assert.That (sent, Is.False, "Busy message sent appearing while not busy");
bool sent = false;
page.Appearing += (sender, args) => sent = true;
- page.SendAppearing ();
+ ((IPageController)page).SendAppearing ();
Assert.True (sent);
}
{
var page = new ContentPage ();
- page.SendAppearing ();
+ ((IPageController)page).SendAppearing ();
bool sent = false;
page.Disappearing += (sender, args) => sent = true;
- page.SendDisappearing ();
+ ((IPageController)page).SendDisappearing ();
Assert.True (sent);
}
int countAppearing = 0;
page.Appearing += (sender, args) => countAppearing++;
- page.SendAppearing ();
- page.SendAppearing ();
+ ((IPageController)page).SendAppearing ();
+ ((IPageController)page).SendAppearing ();
Assert.That (countAppearing, Is.EqualTo(1));
}
};
navPage.Appearing += (sender, e) => sentNav = true;
- navPage.SendAppearing ();
+ ((IPageController)navPage).SendAppearing ();
Assert.True (sentNav);
Assert.True (sent);
var page = new ContentPage ();
var navPage = new NavigationPage (page);
- navPage.SendAppearing ();
+ ((IPageController)navPage).SendAppearing ();
bool sentNav = false;
bool sent = false;
if (sent)
sentNav = true;
};
- navPage.SendDisappearing ();
+ ((IPageController)navPage).SendDisappearing ();
Assert.True (sentNav);
Assert.True (sent);
protected override void LayoutChildren(double x, double y, double width, double height)
{
- foreach (View child in LogicalChildren)
+ foreach (View child in LogicalChildrenInternal)
{
Rectangle rect = ComputeLayoutForRegion(child, new Size(width, height));
rect.X += x;
{
var bestFitSize = new Size();
var minimum = new Size();
- foreach (View child in LogicalChildren)
+ foreach (View child in LogicalChildrenInternal)
{
SizeRequest desiredSize = ComputeBoundingRegionDesiredSize(child);
get { return _propertiesTask.Result; }
}
- internal override ReadOnlyCollection<Element> LogicalChildren
+ internal override ReadOnlyCollection<Element> LogicalChildrenInternal
{
get { return _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren)); }
}
}
}
- internal override ReadOnlyCollection<Element> LogicalChildren => _logicalChildren ?? base.LogicalChildren;
+ internal override ReadOnlyCollection<Element> LogicalChildrenInternal => _logicalChildren ?? base.LogicalChildrenInternal;
}
}
\ No newline at end of file
protected override void LayoutChildren(double x, double y, double width, double height)
{
- for (var i = 0; i < LogicalChildren.Count; i++)
+ for (var i = 0; i < LogicalChildrenInternal.Count; i++)
{
- Element element = LogicalChildren[i];
+ Element element = LogicalChildrenInternal[i];
var child = element as View;
if (child != null)
LayoutChildIntoBoundingRegion(child, new Rectangle(x, y, width, height));
}
}
- internal virtual ReadOnlyCollection<Element> LogicalChildren
- {
- get { return EmptyChildren; }
- }
+ internal virtual ReadOnlyCollection<Element> LogicalChildrenInternal => EmptyChildren;
+
+ ReadOnlyCollection<Element> IElementController.LogicalChildren => LogicalChildrenInternal;
internal bool Owned { get; set; }
var gotBindingContext = false;
object bc = null;
- for (var index = 0; index < LogicalChildren.Count; index++)
+ for (var index = 0; index < LogicalChildrenInternal.Count; index++)
{
- Element child = LogicalChildren[index];
+ Element child = LogicalChildrenInternal[index];
if (!gotBindingContext)
{
while (queue.Count > 0)
{
- ReadOnlyCollection<Element> children = queue.Dequeue().LogicalChildren;
+ ReadOnlyCollection<Element> children = queue.Dequeue().LogicalChildrenInternal;
for (var i = 0; i < children.Count; i++)
{
Element child = children[i];
while (queue.Count > 0)
{
- ReadOnlyCollection<Element> children = queue.Dequeue().LogicalChildren;
+ ReadOnlyCollection<Element> children = queue.Dequeue().LogicalChildrenInternal;
for (var i = 0; i < children.Count; i++)
{
var child = children[i] as VisualElement;
+using System.Collections.ObjectModel;
+
namespace Xamarin.Forms
{
public interface IElementController
void SetValueFromRenderer(BindableProperty property, object value);
void SetValueFromRenderer(BindablePropertyKey propertyKey, object value);
+ ReadOnlyCollection<Element> LogicalChildren { get; }
}
}
\ No newline at end of file
--- /dev/null
+using System.Collections.ObjectModel;
+
+namespace Xamarin.Forms
+{
+ public interface IPageController
+ {
+ Rectangle ContainerArea { get; set; }
+
+ bool IgnoresContainerArea { get; set; }
+
+ ObservableCollection<Element> InternalChildren { get; }
+
+ void SendAppearing();
+
+ void SendDisappearing();
+ }
+}
\ No newline at end of file
internal ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
- internal override ReadOnlyCollection<Element> LogicalChildren
+ internal override ReadOnlyCollection<Element> LogicalChildrenInternal
{
get { return _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren)); }
}
if (!ShouldLayoutChildren())
return;
- var oldBounds = new Rectangle[LogicalChildren.Count];
+ var oldBounds = new Rectangle[LogicalChildrenInternal.Count];
for (var index = 0; index < oldBounds.Length; index++)
{
- var c = (VisualElement)LogicalChildren[index];
+ var c = (VisualElement)LogicalChildrenInternal[index];
oldBounds[index] = c.Bounds;
}
for (var i = 0; i < oldBounds.Length; i++)
{
Rectangle oldBound = oldBounds[i];
- Rectangle newBound = ((VisualElement)LogicalChildren[i]).Bounds;
+ Rectangle newBound = ((VisualElement)LogicalChildrenInternal[i]).Bounds;
if (oldBound != newBound)
{
EventHandler handler = LayoutChanged;
internal virtual void OnChildMeasureInvalidated(VisualElement child, InvalidationTrigger trigger)
{
- ReadOnlyCollection<Element> children = LogicalChildren;
+ ReadOnlyCollection<Element> children = LogicalChildrenInternal;
int count = children.Count;
for (var index = 0; index < count; index++)
{
- var v = LogicalChildren[index] as VisualElement;
+ var v = LogicalChildrenInternal[index] as VisualElement;
if (v != null && v.IsVisible && (!v.IsPlatformEnabled || !v.IsNativeStateConsistent))
return;
}
bool ShouldLayoutChildren()
{
- if (!LogicalChildren.Any() || Width <= 0 || Height <= 0 || !IsVisible || !IsNativeStateConsistent || DisableLayout)
+ if (!LogicalChildrenInternal.Any() || Width <= 0 || Height <= 0 || !IsVisible || !IsNativeStateConsistent || DisableLayout)
return false;
foreach (Element element in VisibleDescendants())
Rectangle _masterBounds;
+ IPageController PageController => this as IPageController;
+
public Page Detail
{
get { return _detail; }
OnPropertyChanging();
if (_detail != null)
- InternalChildren.Remove(_detail);
+ PageController.InternalChildren.Remove(_detail);
_detail = value;
- InternalChildren.Add(_detail);
+ PageController.InternalChildren.Add(_detail);
OnPropertyChanged();
}
}
OnPropertyChanging();
if (_master != null)
- InternalChildren.Remove(_master);
+ PageController.InternalChildren.Remove(_master);
_master = value;
- InternalChildren.Add(_master);
+ PageController.InternalChildren.Add(_master);
OnPropertyChanged();
}
}
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Runtime.CompilerServices;
T _current;
+ ObservableCollection<Element> InternalChildren => ((IPageController)this).InternalChildren;
+
protected MultiPage()
{
_templatedItems = new TemplatedItemsList<MultiPage<T>, T>(this, ItemsSourceProperty, ItemTemplateProperty);
void Reset()
{
- List<Element> snapshot = InternalChildren.ToList();
+ List <Element> snapshot = InternalChildren.ToList();
InternalChildren.Clear();
{
get
{
- var result = new Stack<Page>(InternalChildren.Count);
- foreach (Page page in InternalChildren)
+ var result = new Stack<Page>(PageController.InternalChildren.Count);
+ foreach (Page page in PageController.InternalChildren)
result.Push(page);
return result;
}
int INavigationPageController.StackDepth
{
- get { return InternalChildren.Count; }
+ get { return PageController.InternalChildren.Count; }
}
+ IPageController PageController => this as IPageController;
+
public Page CurrentPage
{
get { return (Page)GetValue(CurrentPageProperty); }
return null;
}
- var page = (Page)InternalChildren.Last();
+ var page = (Page)PageController.InternalChildren.Last();
var args = new NavigationRequestedEventArgs(page, animated);
if (!removed && !fast)
return CurrentPage;
- InternalChildren.Remove(page);
+ PageController.InternalChildren.Remove(page);
- CurrentPage = (Page)InternalChildren.Last();
+ CurrentPage = (Page)PageController.InternalChildren.Last();
if (Popped != null)
Popped(this, args);
void InsertPageBefore(Page page, Page before)
{
- if (!InternalChildren.Contains(before))
+ if (!PageController.InternalChildren.Contains(before))
throw new ArgumentException("before must be a child of the NavigationPage", "before");
- if (InternalChildren.Contains(page))
+ if (PageController.InternalChildren.Contains(page))
throw new ArgumentException("Cannot insert page which is already in the navigation stack");
EventHandler<NavigationRequestedEventArgs> handler = InsertPageBeforeRequestedInternal;
- if (handler != null)
- handler(this, new NavigationRequestedEventArgs(page, before, false));
+ handler?.Invoke(this, new NavigationRequestedEventArgs(page, before, false));
- int index = InternalChildren.IndexOf(before);
- InternalChildren.Insert(index, page);
+ int index = PageController.InternalChildren.IndexOf(before);
+ PageController.InternalChildren.Insert(index, page);
// Shouldn't be required?
if (Width > 0 && Height > 0)
if (((INavigationPageController)this).StackDepth == 1)
return;
- var root = (Page)InternalChildren.First();
+ var root = (Page)PageController.InternalChildren.First();
- InternalChildren.ToArray().Where(c => c != root).ForEach(c => InternalChildren.Remove(c));
+ PageController.InternalChildren.ToArray().Where(c => c != root).ForEach(c => PageController.InternalChildren.Remove(c));
CurrentPage = root;
async Task PushAsyncInner(Page page, bool animated)
{
- if (InternalChildren.Contains(page))
+ if (PageController.InternalChildren.Contains(page))
return;
PushPage(page);
void PushPage(Page page)
{
- InternalChildren.Add(page);
+ PageController.InternalChildren.Add(page);
CurrentPage = page;
}
return;
}
- if (!InternalChildren.Contains(page))
+ if (!PageController.InternalChildren.Contains(page))
throw new ArgumentException("Page to remove must be contained on this Navigation Page");
EventHandler<NavigationRequestedEventArgs> handler = RemovePageRequestedInternal;
if (handler != null)
handler(this, new NavigationRequestedEventArgs(page, true));
- InternalChildren.Remove(page);
+ PageController.InternalChildren.Remove(page);
}
void SafePop()
public NavigationImpl(NavigationPage owner)
{
Owner = owner;
- _castingList = new Lazy<ReadOnlyCastingList<Page, Element>>(() => new ReadOnlyCastingList<Page, Element>(Owner.InternalChildren));
+ _castingList = new Lazy<ReadOnlyCastingList<Page, Element>>(() => new ReadOnlyCastingList<Page, Element>(((IPageController)Owner).InternalChildren));
}
NavigationPage Owner { get; }
namespace Xamarin.Forms
{
[RenderWith(typeof(_PageRenderer))]
- public class Page : VisualElement, ILayout
+ public class Page : VisualElement, ILayout, IPageController
{
- internal const string BusySetSignalName = "Xamarin.BusySet";
+ public const string BusySetSignalName = "Xamarin.BusySet";
- internal const string AlertSignalName = "Xamarin.SendAlert";
+ public const string AlertSignalName = "Xamarin.SendAlert";
- internal const string ActionSheetSignalName = "Xamarin.ShowActionSheet";
+ public const string ActionSheetSignalName = "Xamarin.ShowActionSheet";
internal static readonly BindableProperty IgnoresContainerAreaProperty = BindableProperty.Create("IgnoresContainerArea", typeof(bool), typeof(Page), false);
ReadOnlyCollection<Element> _logicalChildren;
+ IPageController PageController => this as IPageController;
+ IElementController ElementController => this as IElementController;
+
public Page()
{
var toolbarItems = new ObservableCollection<ToolbarItem>();
toolbarItems.CollectionChanged += OnToolbarItemsCollectionChanged;
ToolbarItems = toolbarItems;
- InternalChildren.CollectionChanged += InternalChildrenOnCollectionChanged;
+ PageController.InternalChildren.CollectionChanged += InternalChildrenOnCollectionChanged;
}
public string BackgroundImage
public IList<ToolbarItem> ToolbarItems { get; internal set; }
- internal Rectangle ContainerArea
+ Rectangle IPageController.ContainerArea
{
get { return _containerArea; }
set
}
}
- internal bool IgnoresContainerArea
+ bool IPageController.IgnoresContainerArea
{
get { return (bool)GetValue(IgnoresContainerAreaProperty); }
set { SetValue(IgnoresContainerAreaProperty, value); }
}
- internal ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
+ ObservableCollection<Element> IPageController.InternalChildren { get; } = new ObservableCollection<Element>();
- internal override ReadOnlyCollection<Element> LogicalChildren
- {
- get { return _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren)); }
- }
+ internal override ReadOnlyCollection<Element> LogicalChildrenInternal =>
+ _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(PageController.InternalChildren));
public event EventHandler LayoutChanged;
Rectangle originalArea = area;
if (_containerAreaSet)
{
- area = ContainerArea;
+ area = PageController.ContainerArea;
area.X += Padding.Left;
area.Y += Padding.Right;
area.Width -= Padding.HorizontalThickness;
area.Height = Math.Max(0, area.Height);
}
- foreach (Element element in LogicalChildren)
+ foreach (Element element in ElementController.LogicalChildren)
{
var child = element as VisualElement;
if (child == null)
continue;
var page = child as Page;
- if (page != null && page.IgnoresContainerArea)
+ if (page != null && ((IPageController)page).IgnoresContainerArea)
{
Forms.Layout.LayoutChildIntoBoundingRegion(child, originalArea);
}
if (!ShouldLayoutChildren())
return;
- var startingLayout = new List<Rectangle>(LogicalChildren.Count);
- foreach (VisualElement c in LogicalChildren)
+ var startingLayout = new List<Rectangle>(ElementController.LogicalChildren.Count);
+ foreach (VisualElement c in ElementController.LogicalChildren)
{
startingLayout.Add(c.Bounds);
}
LayoutChildren(x, y, w, h);
- for (var i = 0; i < LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- var c = (VisualElement)LogicalChildren[i];
+ var c = (VisualElement)ElementController.LogicalChildren[i];
if (c.Bounds != startingLayout[i])
{
}
else
{
- for (var i = 0; i < LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- var v = LogicalChildren[i] as VisualElement;
+ var v = ElementController.LogicalChildren[i] as VisualElement;
if (v != null && v.IsVisible && (!v.IsPlatformEnabled || !v.IsNativeStateConsistent))
return;
}
}
}
- internal void SendAppearing()
+ void IPageController.SendAppearing()
{
if (_hasAppeared)
return;
handler(this, EventArgs.Empty);
var pageContainer = this as IPageContainer<Page>;
- pageContainer?.CurrentPage?.SendAppearing();
+ ((IPageController)pageContainer?.CurrentPage)?.SendAppearing();
}
- internal void SendDisappearing()
+ void IPageController.SendDisappearing()
{
if (!_hasAppeared)
return;
MessagingCenter.Send(this, BusySetSignalName, false);
var pageContainer = this as IPageContainer<Page>;
- pageContainer?.CurrentPage?.SendDisappearing();
+ ((IPageController)pageContainer?.CurrentPage)?.SendDisappearing();
OnDisappearing();
EventHandler handler = Disappearing;
bool ShouldLayoutChildren()
{
- if (!LogicalChildren.Any() || Width <= 0 || Height <= 0 || !IsNativeStateConsistent)
+ if (!ElementController.LogicalChildren.Any() || Width <= 0 || Height <= 0 || !IsNativeStateConsistent)
return false;
var container = this as IPageContainer<Page>;
- if (container != null && container.CurrentPage != null)
+ if (container?.CurrentPage != null)
{
- if (InternalChildren.Contains(container.CurrentPage))
+ if (PageController.InternalChildren.Contains(container.CurrentPage))
return container.CurrentPage.IsPlatformEnabled && container.CurrentPage.IsNativeStateConsistent;
return true;
}
var any = false;
- for (var i = 0; i < LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- var v = LogicalChildren[i] as VisualElement;
+ var v = ElementController.LogicalChildren[i] as VisualElement;
if (v != null && (!v.IsPlatformEnabled || !v.IsNativeStateConsistent))
{
any = true;
LayoutInformation layoutInformationCopy = _layoutInformation;
- for (var i = 0; i < LogicalChildren.Count; i++)
+ for (var i = 0; i < LogicalChildrenInternal.Count; i++)
{
- var child = (View)LogicalChildren[i];
+ var child = (View)LogicalChildrenInternal[i];
if (child.IsVisible)
LayoutChildIntoBoundingRegion(child, layoutInformationCopy.Plots[i], layoutInformationCopy.Requests[i]);
}
{
for (var i = 0; i < layout.Plots.Length; i++)
{
- if (!((View)LogicalChildren[i]).IsVisible)
+ if (!((View)LogicalChildrenInternal[i]).IsVisible)
continue;
if (orientation == StackOrientation.Vertical)
{
if (orientation == StackOrientation.Vertical)
{
View expander = null;
- for (var i = 0; i < LogicalChildren.Count; i++)
+ for (var i = 0; i < LogicalChildrenInternal.Count; i++)
{
- var child = (View)LogicalChildren[i];
+ var child = (View)LogicalChildrenInternal[i];
if (!child.IsVisible)
continue;
else
{
View expander = null;
- for (var i = 0; i < LogicalChildren.Count; i++)
+ for (var i = 0; i < LogicalChildrenInternal.Count; i++)
{
- var child = (View)LogicalChildren[i];
+ var child = (View)LogicalChildrenInternal[i];
if (!child.IsVisible)
continue;
for (var i = 0; i < layout.Plots.Length; i++)
{
- var child = (View)LogicalChildren[i];
+ var child = (View)LogicalChildrenInternal[i];
if (!child.IsVisible)
continue;
for (var i = 0; i < layout.Plots.Length; i++)
{
- var child = (View)LogicalChildren[i];
+ var child = (View)LogicalChildrenInternal[i];
if (!child.IsVisible)
continue;
double spacePerExpander = extraSpace / layout.Expanders;
double yOffset = 0;
- for (var i = 0; i < LogicalChildren.Count; i++)
+ for (var i = 0; i < LogicalChildrenInternal.Count; i++)
{
- var child = (View)LogicalChildren[i];
+ var child = (View)LogicalChildrenInternal[i];
if (!child.IsVisible)
continue;
Rectangle plot = layout.Plots[i];
double spacePerExpander = extraSpace / layout.Expanders;
double xOffset = 0;
- for (var i = 0; i < LogicalChildren.Count; i++)
+ for (var i = 0; i < LogicalChildrenInternal.Count; i++)
{
- var child = (View)LogicalChildren[i];
+ var child = (View)LogicalChildrenInternal[i];
if (!child.IsVisible)
continue;
Rectangle plot = layout.Plots[i];
while (queue.Count > 0)
{
- ReadOnlyCollection<Element> children = queue.Dequeue().LogicalChildren;
+ ReadOnlyCollection<Element> children = queue.Dequeue().LogicalChildrenInternal;
for (var i = 0; i < children.Count; i++)
{
Element child = children[i];
set { SetValue(ControlTemplateProperty, value); }
}
- IList<Element> IControlTemplated.InternalChildren => InternalChildren;
+ IList<Element> IControlTemplated.InternalChildren => ((IPageController)this).InternalChildren;
internal override void ComputeConstraintForView(View view)
{
protected override void LayoutChildren(double x, double y, double width, double height)
{
- for (var i = 0; i < LogicalChildren.Count; i++)
+ for (var i = 0; i < LogicalChildrenInternal.Count; i++)
{
- Element element = LogicalChildren[i];
+ Element element = LogicalChildrenInternal[i];
var child = element as View;
if (child != null)
LayoutChildIntoBoundingRegion(child, new Rectangle(x, y, width, height));
internal void ComputeConstrainsForChildren()
{
- for (var i = 0; i < LogicalChildren.Count; i++)
+ for (var i = 0; i < LogicalChildrenInternal.Count; i++)
{
- var child = LogicalChildren[i] as View;
+ var child = LogicalChildrenInternal[i] as View;
if (child != null)
ComputeConstraintForView(child);
}
<Compile Include="Internals\InvalidationTrigger.cs" />
<Compile Include="InvalidNavigationException.cs" />
<Compile Include="IOpenGlViewController.cs" />
+ <Compile Include="IPageController.cs" />
<Compile Include="IPanGestureController.cs" />
<Compile Include="IPinchGestureController.cs" />
<Compile Include="IProvideParentValues.cs" />
{
}
+ IPageController PageController => Element as IPageController;
+
void ViewPager.IOnPageChangeListener.OnPageSelected(int position)
{
Element.CurrentPage = Element.Children[position];
}
if (Element != null)
- Element.InternalChildren.CollectionChanged -= OnChildrenCollectionChanged;
+ PageController.InternalChildren.CollectionChanged -= OnChildrenCollectionChanged;
}
base.Dispose(disposing);
protected override void OnAttachedToWindow()
{
base.OnAttachedToWindow();
- Element.SendAppearing();
+ PageController.SendAppearing();
}
protected override void OnDetachedFromWindow()
{
base.OnDetachedFromWindow();
- Element.SendDisappearing();
+ PageController.SendDisappearing();
}
protected override void OnElementChanged(ElementChangedEventArgs<CarouselPage> e)
var activity = (FormsAppCompatActivity)Context;
if (e.OldElement != null)
- e.OldElement.InternalChildren.CollectionChanged -= OnChildrenCollectionChanged;
+ ((IPageController)e.OldElement).InternalChildren.CollectionChanged -= OnChildrenCollectionChanged;
if (e.NewElement != null)
{
if (carouselPage.CurrentPage != null)
ScrollToCurrentPage();
- carouselPage.InternalChildren.CollectionChanged += OnChildrenCollectionChanged;
+ ((IPageController)carouselPage).InternalChildren.CollectionChanged += OnChildrenCollectionChanged;
}
}
if (width > 0 && height > 0)
{
- Element.ContainerArea = new Rectangle(0, 0, context.FromPixels(width), context.FromPixels(height));
+ PageController.ContainerArea = new Rectangle(0, 0, context.FromPixels(width), context.FromPixels(height));
pager.Layout(0, 0, width, b);
}
public Page Page => (Page)_pageReference?.Target;
+ IPageController PageController => Page as IPageController;
+
public override bool UserVisibleHint
{
get { return base.UserVisibleHint; }
return;
_isVisible = value;
if (_isVisible.Value)
- Page?.SendAppearing();
+ PageController?.SendAppearing();
else
- Page?.SendDisappearing();
+ PageController?.SendDisappearing();
}
}
return;
if (hidden)
- Page.SendDisappearing();
+ PageController.SendDisappearing();
else
- Page.SendAppearing();
+ PageController.SendAppearing();
}
public override void OnPause()
{
- Page?.SendDisappearing();
+ PageController?.SendDisappearing();
base.OnPause();
}
public override void OnResume()
{
- Page?.SendAppearing();
+ PageController?.SendAppearing();
base.OnResume();
}
}
if (Element == null)
return;
- var children = Element.LogicalChildren;
+ var children = ((IElementController)Element).LogicalChildren;
for (var i = 0; i < children.Count; i++)
{
var visualElement = children[i] as VisualElement;
}
}
+ IPageController MasterPageController => Element.Master as IPageController;
+ IPageController DetailPageController => Element.Detail as IPageController;
+ IPageController PageController => Element as IPageController;
+
void IDrawerListener.OnDrawerClosed(global::Android.Views.View drawerView)
{
}
protected override void OnAttachedToWindow()
{
base.OnAttachedToWindow();
- Element.SendAppearing();
+ PageController.SendAppearing();
}
protected override void OnDetachedFromWindow()
{
base.OnDetachedFromWindow();
- Element.SendDisappearing();
+ PageController.SendDisappearing();
}
protected virtual void OnElementChanged(VisualElement oldElement, VisualElement newElement)
void MasterDetailPageAppearing(object sender, EventArgs e)
{
- Element.Master?.SendAppearing();
- Element.Detail?.SendAppearing();
+ MasterPageController?.SendAppearing();
+ DetailPageController?.SendAppearing();
}
void MasterDetailPageDisappearing(object sender, EventArgs e)
{
- Element.Master?.SendDisappearing();
- Element.Detail?.SendDisappearing();
+ MasterPageController?.SendDisappearing();
+ DetailPageController?.SendDisappearing();
}
void OnBackButtonPressed(object sender, BackButtonPressedEventArgs backButtonPressedEventArgs)
FragmentManager FragmentManager => _fragmentManager ?? (_fragmentManager = ((FormsAppCompatActivity)Context).SupportFragmentManager);
+ IPageController PageController => Element as IPageController;
+
bool ToolbarVisible
{
get { return _toolbarVisible; }
if (Element != null)
{
- for (var i = 0; i < Element.InternalChildren.Count; i++)
+ for (var i = 0; i < PageController.InternalChildren.Count; i++)
{
- var child = Element.InternalChildren[i] as VisualElement;
+ var child = PageController.InternalChildren[i] as VisualElement;
if (child == null)
continue;
IVisualElementRenderer renderer = Android.Platform.GetRenderer(child);
navController.PopToRootRequested -= OnPoppedToRoot;
navController.InsertPageBeforeRequested -= OnInsertPageBeforeRequested;
navController.RemovePageRequested -= OnRemovePageRequested;
- Element.SendDisappearing();
+ PageController.SendDisappearing();
}
if (_toolbarTracker != null)
protected override void OnAttachedToWindow()
{
base.OnAttachedToWindow();
- Element.SendAppearing();
+ PageController.SendAppearing();
_fragmentStack.Last().UserVisibleHint = true;
RegisterToolbar();
UpdateToolbar();
protected override void OnDetachedFromWindow()
{
base.OnDetachedFromWindow();
- Element.SendDisappearing();
+ PageController.SendDisappearing();
}
protected override void OnElementChanged(ElementChangedEventArgs<NavigationPage> e)
int containerHeight = ToolbarVisible ? internalHeight : b - t;
containerHeight -= ContainerPadding;
- Element.ContainerArea = new Rectangle(0, 0, Context.FromPixels(r - l), Context.FromPixels(containerHeight));
+ PageController.ContainerArea = new Rectangle(0, 0, Context.FromPixels(r - l), Context.FromPixels(containerHeight));
// Potential for optimization here, the exact conditions by which you don't need to do this are complex
// and the cost of doing when it's not needed is moderate to low since the layout will short circuit pretty fast
Element.ForceLayout();
{
UpdateToolbar();
- int index = Element.InternalChildren.IndexOf(before);
+ int index = PageController.InternalChildren.IndexOf(before);
if (index == -1)
throw new InvalidOperationException("This should never happen, please file a bug");
if (masterDetailPage == null)
{
- masterDetailPage = Element.InternalChildren[0] as MasterDetailPage;
+ masterDetailPage = PageController.InternalChildren[0] as MasterDetailPage;
if (masterDetailPage == null)
return;
}
Page Page { get; set; }
+ IPageController CurrentPageController => _navModel.CurrentPage as IPageController;
+
public void Dispose()
{
if (_disposed)
Task<Page> INavigation.PopModalAsync(bool animated)
{
Page modal = _navModel.PopModal();
- modal.SendDisappearing();
+ ((IPageController)modal).SendDisappearing();
var source = new TaskCompletionSource<Page>();
IVisualElementRenderer modalRenderer = Android.Platform.GetRenderer(modal);
modalContainer.RemoveFromParent();
modalContainer.Dispose();
source.TrySetResult(modal);
- _navModel.CurrentPage?.SendAppearing();
+ CurrentPageController?.SendAppearing();
modalContainer = null;
}
});
modalContainer.RemoveFromParent();
modalContainer.Dispose();
source.TrySetResult(modal);
- _navModel.CurrentPage?.SendAppearing();
+ CurrentPageController?.SendAppearing();
}
}
async Task INavigation.PushModalAsync(Page modal, bool animated)
{
- _navModel.CurrentPage?.SendDisappearing();
+ CurrentPageController?.SendDisappearing();
_navModel.PushModal(modal);
// Verify that the modal is still on the stack
if (_navModel.CurrentPage == modal)
- modal.SendAppearing();
+ ((IPageController)modal).SendAppearing();
}
void INavigation.RemovePage(Page page)
}
}
+ IPageController PageController => Element as IPageController;
+
void IManageFragments.SetFragmentManager(FragmentManager childFragmentManager)
{
if (_fragmentManager == null)
}
if (Element != null)
- Element.InternalChildren.CollectionChanged -= OnChildrenCollectionChanged;
+ PageController.InternalChildren.CollectionChanged -= OnChildrenCollectionChanged;
}
base.Dispose(disposing);
protected override void OnAttachedToWindow()
{
base.OnAttachedToWindow();
- Element.SendAppearing();
+ PageController.SendAppearing();
}
protected override void OnDetachedFromWindow()
{
base.OnDetachedFromWindow();
- Element.SendDisappearing();
+ PageController.SendDisappearing();
}
protected override void OnElementChanged(ElementChangedEventArgs<TabbedPage> e)
var activity = (FormsAppCompatActivity)Context;
if (e.OldElement != null)
- e.OldElement.InternalChildren.CollectionChanged -= OnChildrenCollectionChanged;
+ ((IPageController)e.OldElement).InternalChildren.CollectionChanged -= OnChildrenCollectionChanged;
if (e.NewElement != null)
{
ScrollToCurrentPage();
UpdateIgnoreContainerAreas();
- tabbedPage.InternalChildren.CollectionChanged += OnChildrenCollectionChanged;
+ ((IPageController)tabbedPage).InternalChildren.CollectionChanged += OnChildrenCollectionChanged;
UpdateBarBackgroundColor();
UpdateBarTextColor();
}
if (width > 0 && height > 0)
{
- Element.ContainerArea = new Rectangle(0, context.FromPixels(tabsHeight), context.FromPixels(width), context.FromPixels(height - tabsHeight));
+ PageController.ContainerArea = new Rectangle(0, context.FromPixels(tabsHeight), context.FromPixels(width), context.FromPixels(height - tabsHeight));
- for (var i = 0; i < Element.InternalChildren.Count; i++)
+ for (var i = 0; i < PageController.InternalChildren.Count; i++)
{
- var child = Element.InternalChildren[i] as VisualElement;
+ var child = PageController.InternalChildren[i] as VisualElement;
if (child == null)
continue;
IVisualElementRenderer renderer = Android.Platform.GetRenderer(child);
void UpdateIgnoreContainerAreas()
{
- foreach (Page child in Element.Children)
+ foreach (IPageController child in Element.Children)
child.IgnoresContainerArea = child is NavigationPage;
}
{
TabLayout tabs = _tabLayout;
- if (position >= Element.InternalChildren.Count)
+ if (position >= PageController.InternalChildren.Count)
return;
- var leftPage = (Page)Element.InternalChildren[position];
+ var leftPage = (Page)PageController.InternalChildren[position];
IVisualElementRenderer leftRenderer = Android.Platform.GetRenderer(leftPage);
if (leftRenderer == null)
return;
- if (offset <= 0 || position >= Element.InternalChildren.Count - 1)
+ if (offset <= 0 || position >= PageController.InternalChildren.Count - 1)
{
var leftNavRenderer = leftRenderer as NavigationPageRenderer;
if (leftNavRenderer != null)
}
else
{
- var rightPage = (Page)Element.InternalChildren[position + 1];
+ var rightPage = (Page)PageController.InternalChildren[position + 1];
IVisualElementRenderer rightRenderer = Android.Platform.GetRenderer(rightPage);
var leftHeight = 0;
#endregion
+ IPageController CurrentPageController => _navModel.CurrentPage as IPageController;
+
ActionBar ActionBar
{
get { return ((Activity)_context).ActionBar; }
{
Page modal = _navModel.PopModal();
- modal.SendDisappearing();
+ ((IPageController)modal).SendDisappearing();
var source = new TaskCompletionSource<Page>();
IVisualElementRenderer modalRenderer = GetRenderer(modal);
modalRenderer.ViewGroup.RemoveFromParent();
modalRenderer.Dispose();
source.TrySetResult(modal);
- _navModel.CurrentPage?.SendAppearing();
+ CurrentPageController?.SendAppearing();
}
});
}
modalRenderer.ViewGroup.RemoveFromParent();
modalRenderer.Dispose();
source.TrySetResult(modal);
- _navModel.CurrentPage?.SendAppearing();
+ CurrentPageController?.SendAppearing();
}
}
async Task INavigation.PushModalAsync(Page modal, bool animated)
{
- _navModel.CurrentPage?.SendDisappearing();
+ CurrentPageController?.SendDisappearing();
_navModel.PushModal(modal);
// Verify that the modal is still on the stack
if (_navModel.CurrentPage == modal)
- modal.SendAppearing();
+ ((IPageController)modal).SendAppearing();
_toolbarTracker.Target = _navModel.Roots.Last();
result.AddRange(AncestorPagesOfPage(((MasterDetailPage)root).Detail));
else
{
- foreach (Page page in root.InternalChildren.OfType<Page>())
+ foreach (Page page in ((IPageController)root).InternalChildren.OfType<Page>())
result.AddRange(AncestorPagesOfPage(page));
}
public void ClearChildrenRenderers()
{
- if (_parent.Element.LogicalChildren.Count == 0)
+ if (((IElementController)_parent.Element).LogicalChildren.Count == 0)
return;
ClearChildrenRenderers(_oldElement);
}
if (view == null)
return;
- foreach (Element logicalChild in view.LogicalChildren)
+ foreach (Element logicalChild in ((IElementController)view).LogicalChildren)
{
var child = logicalChild as VisualElement;
if (child != null)
bool _ignoreAndroidSelection;
CarouselPage _page;
+ IElementController ElementController => _page as IElementController;
+
public CarouselPageAdapter(ViewPager pager, CarouselPage page, Context context)
{
_pager = pager;
return;
int currentItem = _pager.CurrentItem;
- _page.CurrentPage = currentItem >= 0 && currentItem < _page.LogicalChildren.Count ? _page.LogicalChildren[currentItem] as ContentPage : null;
+ _page.CurrentPage = currentItem >= 0 && currentItem < ElementController.LogicalChildren.Count ? ElementController.LogicalChildren[currentItem] as ContentPage : null;
}
public override void DestroyItem(ViewGroup p0, int p1, Object p2)
{
if (disposing && _page != null)
{
- foreach (Element element in _page.LogicalChildren)
+ foreach (Element element in ElementController.LogicalChildren)
{
var childPage = element as VisualElement;
AutoPackage = false;
}
+ IPageController PageController => Element as IPageController;
+
protected override void Dispose(bool disposing)
{
if (disposing && _viewPager != null)
adapter.UpdateCurrentItem();
- Element.SendAppearing();
+ PageController.SendAppearing();
}
protected override void OnDetachedFromWindow()
{
base.OnDetachedFromWindow();
- Element.SendDisappearing();
+ PageController.SendDisappearing();
}
protected override void OnElementChanged(ElementChangedEventArgs<CarouselPage> e)
void UpdateCurrentItem()
{
int index = CarouselPage.GetIndex(Element.CurrentPage);
- if (index < 0 || index >= Element.LogicalChildren.Count)
+ if (index < 0 || index >= ((IElementController)Element).LogicalChildren.Count)
return;
_viewPager.CurrentItem = index;
{
bool _isDisposed;
+ IElementController ElementController => Element as IElementController;
+
public ImageRenderer()
{
AutoPackage = false;
if (!_isDisposed)
{
Control.SetImageBitmap(bitmap);
- if (bitmap != null)
- bitmap.Dispose();
+ bitmap?.Dispose();
((IImageController)Element).SetIsLoading(false);
((IVisualElementController)Element).NativeSizeChanged();
}
}
+ IPageController MasterPageController => _page.Master as IPageController;
+ IPageController DetailPageController => _page.Detail as IPageController;
+ IPageController PageController => Element as IPageController;
+
public void OnDrawerClosed(AView drawerView)
{
}
protected override void OnAttachedToWindow()
{
base.OnAttachedToWindow();
- ((Page)Element).SendAppearing();
+ PageController.SendAppearing();
}
protected override void OnDetachedFromWindow()
{
base.OnDetachedFromWindow();
- ((Page)Element).SendDisappearing();
+ PageController.SendDisappearing();
}
protected virtual void OnElementChanged(VisualElement oldElement, VisualElement newElement)
void MasterDetailPageAppearing(object sender, EventArgs e)
{
- if (_page.Master != null)
- _page.Master.SendAppearing();
-
- if (_page.Detail != null)
- _page.Detail.SendAppearing();
+ MasterPageController?.SendAppearing();
+ DetailPageController?.SendAppearing();
}
void MasterDetailPageDisappearing(object sender, EventArgs e)
{
- if (_page.Master != null)
- _page.Master.SendDisappearing();
-
- if (_page.Detail != null)
- _page.Detail.SendDisappearing();
+ MasterPageController?.SendDisappearing();
+ DetailPageController?.SendDisappearing();
}
void OnBackButtonPressed(object sender, BackButtonPressedEventArgs backButtonPressedEventArgs)
return OnPushAsync(page, animated);
}
+ IPageController PageController => Element as IPageController;
+
protected override void Dispose(bool disposing)
{
if (disposing)
{
- foreach (VisualElement child in Element.InternalChildren)
+ foreach (VisualElement child in PageController.InternalChildren)
{
IVisualElementRenderer renderer = Platform.GetRenderer(child);
if (renderer != null)
protected override void OnAttachedToWindow()
{
base.OnAttachedToWindow();
- Element.SendAppearing();
+ PageController.SendAppearing();
}
protected override void OnDetachedFromWindow()
{
base.OnDetachedFromWindow();
- Element.SendDisappearing();
+ PageController.SendDisappearing();
}
protected override void OnElementChanged(ElementChangedEventArgs<NavigationPage> e)
void InsertPageBefore(Page page, Page before)
{
- int index = Element.InternalChildren.IndexOf(before);
+ int index = ((IPageController)Element).InternalChildren.IndexOf(before);
if (index == -1)
throw new InvalidOperationException("This should never happen, please file a bug");
{
// animate out
if (containerToAdd.Parent != this)
- AddView(containerToAdd, Element.LogicalChildren.IndexOf(rendererToAdd.Element));
+ AddView(containerToAdd, ((IElementController)Element).LogicalChildren.IndexOf(rendererToAdd.Element));
else
- ((Page)rendererToAdd.Element).SendAppearing();
+ ((IPageController)rendererToAdd.Element).SendAppearing();
containerToAdd.Visibility = ViewStates.Visible;
if (containerToRemove != null)
if (!containerAlreadyAdded)
AddView(containerToAdd);
else
- ((Page)rendererToAdd.Element).SendAppearing();
+ ((IPageController)rendererToAdd.Element).SendAppearing();
if (existing)
Element.ForceLayout();
if (containerToRemove != null && containerToRemove.Handle != IntPtr.Zero)
{
containerToRemove.Visibility = ViewStates.Gone;
- if (pageToRemove != null)
- pageToRemove.SendDisappearing();
+ ((IPageController)pageToRemove)?.SendDisappearing();
}
s_currentAnimation = null;
tcs.TrySetResult(true);
if (containerToAdd.Parent != this)
AddView(containerToAdd);
else
- ((Page)rendererToAdd.Element).SendAppearing();
+ ((IPageController)rendererToAdd.Element).SendAppearing();
if (containerToRemove != null && !removed)
- pageToRemove.SendDisappearing();
+ ((IPageController)pageToRemove).SendDisappearing();
if (existing)
Element.ForceLayout();
return true;
}
+ IPageController PageController => Element as IPageController;
+
protected override void Dispose(bool disposing)
{
- Element?.SendDisappearing();
+ PageController?.SendDisappearing();
base.Dispose(disposing);
}
var pageContainer = Parent as PageContainer;
if (pageContainer != null && pageContainer.IsInFragment)
return;
- Element.SendAppearing();
+ PageController.SendAppearing();
}
protected override void OnDetachedFromWindow()
var pageContainer = Parent as PageContainer;
if (pageContainer != null && pageContainer.IsInFragment)
return;
- Element.SendDisappearing();
+ PageController.SendDisappearing();
}
protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
AutoPackage = false;
}
+ IElementController ElementController => Element as IElementController;
+
protected override void Dispose(bool disposing)
{
if (disposing && !_isDisposed)
else if (_dialog != null)
{
_dialog.Hide();
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
Control.ClearFocus();
_dialog = null;
}
var layout = new LinearLayout(Context) { Orientation = Orientation.Vertical };
layout.AddView(picker);
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
var builder = new AlertDialog.Builder(Context);
builder.SetView(layout);
builder.SetTitle(model.Title ?? "");
builder.SetNegativeButton(global::Android.Resource.String.Cancel, (s, a) =>
{
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
// It is possible for the Content of the Page to be changed when Focus is changed.
// In this case, we'll lose our Control.
Control?.ClearFocus();
});
builder.SetPositiveButton(global::Android.Resource.String.Ok, (s, a) =>
{
- ((IElementController)Element).SetValueFromRenderer(Picker.SelectedIndexProperty, picker.Value);
+ ElementController.SetValueFromRenderer(Picker.SelectedIndexProperty, picker.Value);
// It is possible for the Content of the Page to be changed on SelectedIndexChanged.
// In this case, the Element & Control will no longer exist.
if (Element != null)
{
if (model.Items.Count > 0 && Element.SelectedIndex >= 0)
Control.Text = model.Items[Element.SelectedIndex];
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
// It is also possible for the Content of the Page to be changed when Focus is changed.
// In this case, we'll lose our Control.
Control?.ClearFocus();
AutoPackage = false;
}
+ IPageController PageController => Element as IPageController;
+
protected override void Dispose(bool disposing)
{
if (disposing && Element != null && Element.Children.Count > 0)
protected override void OnAttachedToWindow()
{
base.OnAttachedToWindow();
- Element.SendAppearing();
+ PageController.SendAppearing();
}
protected override void OnDetachedFromWindow()
{
base.OnDetachedFromWindow();
- Element.SendDisappearing();
+ PageController.SendDisappearing();
}
protected override void OnElementChanged(ElementChangedEventArgs<TabbedPage> e)
AutoPackage = false;
}
+ IElementController ElementController => Element as IElementController;
+
void TimePickerDialog.IOnTimeSetListener.OnTimeSet(ATimePicker view, int hourOfDay, int minute)
{
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
- ((IElementController)Element).SetValueFromRenderer(TimePicker.TimeProperty, new TimeSpan(hourOfDay, minute, 0));
+ ElementController.SetValueFromRenderer(TimePicker.TimeProperty, new TimeSpan(hourOfDay, minute, 0));
Control.ClearFocus();
_dialog = null;
}
else if (_dialog != null)
{
_dialog.Hide();
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
Control.ClearFocus();
_dialog = null;
}
void OnClick()
{
TimePicker view = Element;
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
_dialog = new TimePickerDialog(Context, this, view.Time.Hours, view.Time.Minutes, false);
_dialog.Show();
_renderer.ElementChanged += (sender, args) => SetElement(args.OldElement, args.NewElement);
}
+ IElementController ElementController => _renderer.Element as IElementController;
+
public void Dispose()
{
if (_disposed)
void EnsureChildOrder()
{
- for (var i = 0; i < _renderer.Element.LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- Element child = _renderer.Element.LogicalChildren[i];
+ Element child = ElementController.LogicalChildren[i];
var element = (VisualElement)child;
if (element != null)
{
var view = e.Element as VisualElement;
if (view != null)
AddChild(view);
- if (_renderer.Element.LogicalChildren[_renderer.Element.LogicalChildren.Count - 1] != view)
+
+ if (ElementController.LogicalChildren[ElementController.LogicalChildren.Count - 1] != view)
EnsureChildOrder();
}
{
sameChildrenTypes = true;
- oldChildren = oldElement.LogicalChildren;
- newChildren = newElement.LogicalChildren;
+ oldChildren = ((IElementController)oldElement).LogicalChildren;
+ newChildren = ((IElementController)newElement).LogicalChildren;
if (oldChildren.Count == newChildren.Count)
{
for (var i = 0; i < oldChildren.Count; i++)
newElement.ChildrenReordered += _childReorderedHandler;
- newChildren = newChildren ?? newElement.LogicalChildren;
+ newChildren = newChildren ?? ((IElementController)newElement).LogicalChildren;
for (var i = 0; i < newChildren.Count; i++)
{
if (Element == null)
return;
- ReadOnlyCollection<Element> children = Element.LogicalChildren;
+ ReadOnlyCollection<Element> children = ((IElementController)Element).LogicalChildren;
for (var i = 0; i < children.Count; i++)
{
var visualElement = children[i] as VisualElement;
{
set { Control.ToolbarForeground = value; }
}
+
+IPageController PageController => Element as IPageController;
IMasterDetailPageController MasterDetailPageController => Element as IMasterDetailPageController;
if (Element == null)
return;
- Element.SendAppearing();
+ PageController.SendAppearing();
UpdateBounds();
}
void OnControlUnlaoded(object sender, RoutedEventArgs routedEventArgs)
{
- if (Element == null)
- return;
-
- Element.SendDisappearing();
+ PageController?.SendDisappearing();
}
void OnDetailPropertyChanged(object sender, PropertyChangedEventArgs e)
if (ActualWidth > 0 && ActualHeight > 0)
{
var tab = (Page)DataContext;
- ((TabbedPage)tab.RealParent).ContainerArea = new Rectangle(0, 0, ActualWidth, ActualHeight);
+ ((IPageController)tab.RealParent).ContainerArea = new Rectangle(0, 0, ActualWidth, ActualHeight);
}
};
}
void TabbedPagePresenter_Loaded(object sender, RoutedEventArgs e)
{
- var tab = (Page)DataContext;
+ var tab = (IPageController)DataContext;
tab.SendAppearing();
}
void TabbedPagePresenter_Unloaded(object sender, RoutedEventArgs e)
{
- var tab = (Page)DataContext;
+ var tab = (IPageController)DataContext;
tab.SendDisappearing();
}
}
set { (Control as FormsPivot).ToolbarForeground = value; }
}
+ IPageController PageController => Element as IPageController;
+
bool ITitleProvider.ShowTitle
{
get { return _showTitle; }
return;
_disposed = true;
- Element?.SendDisappearing();
+ PageController?.SendDisappearing();
SetElement(null);
Tracker = null;
}
void OnLoaded(object sender, RoutedEventArgs args)
{
- if (Element == null)
- return;
-
- Element.SendAppearing();
+ PageController?.SendAppearing();
}
void OnPagesChanged(object sender, NotifyCollectionChangedEventArgs e)
Page currentPage = Element.CurrentPage;
if (currentPage == page)
return;
- currentPage?.SendDisappearing();
+ ((IPageController)currentPage)?.SendDisappearing();
Element.CurrentPage = page;
- page?.SendAppearing();
+ ((IPageController)page)?.SendAppearing();
}
void OnUnloaded(object sender, RoutedEventArgs args)
{
- if (Element == null)
- return;
-
- Element.SendDisappearing();
+ PageController?.SendDisappearing();
}
Brush GetBarBackgroundBrush()
if (element.ActualWidth > 0 && element.ActualHeight > 0)
{
var carouselItem = (Page)DataContext;
- ((CarouselPage)carouselItem.RealParent).ContainerArea = new Rectangle(0, 0, element.ActualWidth, element.ActualHeight);
+ ((IPageController)carouselItem.RealParent).ContainerArea = new Rectangle(0, 0, element.ActualWidth, element.ActualHeight);
}
};
}
_page.PagesChanged += OnPagesChanged;
_page.PropertyChanged += OnPropertyChanged;
- Loaded += (sender, args) => _page.SendAppearing();
- Unloaded += (sender, args) => _page.SendDisappearing();
+ Loaded += (sender, args) => ((IPageController)_page).SendAppearing();
+ Unloaded += (sender, args) => ((IPageController)_page).SendDisappearing();
OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));
}
public class ImageRenderer : ViewRenderer<Image, System.Windows.Controls.Image>
{
+ IElementController ElementController => Element as IElementController;
+
public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
{
// Someone reported a NRE happening in this method which can only be explained by Control being null
public bool Visible { get; private set; }
+ IPageController PageController => Element as IPageController;
+
protected override System.Windows.Size ArrangeOverride(System.Windows.Size finalSize)
{
UpdateSizes(finalSize.Width, finalSize.Height);
{
if (Element.IsPresented)
Toggle();
- Element.SendAppearing();
+ PageController.SendAppearing();
};
Unloaded += (sender, args) =>
{
- Element.SendDisappearing();
+ PageController.SendDisappearing();
if (Visible)
{
var platform = (Platform)Element.Platform;
AutoPackage = false;
}
+ IPageController PageController => Element as IPageController;
+ IElementController ElementController => Element as IElementController;
+
protected override void OnElementChanged(ElementChangedEventArgs<NavigationPage> e)
{
base.OnElementChanged(e);
Element.PropertyChanged += OnElementPropertyChanged;
var platform = (Platform)Element.Platform;
- Element.ContainerArea = new Rectangle(new Point(0, 0), platform.Size);
- platform.SizeChanged += (sender, args) => Element.ContainerArea = new Rectangle(new Point(0, 0), platform.Size);
+ PageController.ContainerArea = new Rectangle(new Point(0, 0), platform.Size);
+
+ platform.SizeChanged += (sender, args) => PageController.ContainerArea = new Rectangle(new Point(0, 0), platform.Size);
List<Page> stack = GetStack();
if (stack.Count > 0)
else
init();
- Loaded += (sender, args) => Element.SendAppearing();
+ Loaded += (sender, args) => PageController.SendAppearing();
Unloaded += OnUnloaded;
}
List<Page> GetStack()
{
- int count = Element.InternalChildren.Count;
+ int count = PageController.InternalChildren.Count;
var stack = new List<Page>(count);
for (var i = 0; i < count; i++)
- stack.Add((Page)Element.InternalChildren[i]);
+ stack.Add((Page)PageController.InternalChildren[i]);
return stack;
}
if (platform == null)
return;
- for (var i = 0; i < Element.LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- var page = Element.LogicalChildren[i] as Page;
+ var page = ElementController.LogicalChildren[i] as Page;
if (page != null)
platform.RemovePage(page, false);
}
void OnUnloaded(object sender, RoutedEventArgs args)
{
- Element.SendDisappearing();
+ PageController.SendDisappearing();
}
void PageOnPopped(object sender, NavigationRequestedEventArgs eventArg)
if (platform != null)
{
if (e.Page == ((INavigationPageController)Element).StackCopy.LastOrDefault())
- e.Page.IgnoresContainerArea = true;
+ ((IPageController)e.Page).IgnoresContainerArea = true;
e.Task = platform.PushCore(e.Page, Element, e.Animated, e.Realize).ContinueWith((t, o) => true, null);
}
}
{
Children.RemoveAt(0);
- var page = renderer.Element as Page;
+ var page = renderer.Element as IPageController;
if (page != null)
page.IgnoresContainerArea = false;
if (first == null)
return;
- first.IgnoresContainerArea = true;
+ ((IPageController)first).IgnoresContainerArea = true;
IVisualElementRenderer firstRenderer = Platform.GetRenderer(first);
if (firstRenderer == null)
base.OnElementChanged(e);
- Loaded += (sender, args) => Element.SendAppearing();
- Unloaded += (sender, args) => Element.SendDisappearing();
+ Loaded += (sender, args) => ((IPageController)Element).SendAppearing();
+ Unloaded += (sender, args) => ((IPageController)Element).SendDisappearing();
}
}
}
\ No newline at end of file
FormsListPicker _listPicker;
Brush _defaultBrush;
+ IElementController ElementController => Element as IElementController;
+
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
_listPicker = new FormsListPicker();
if (oldVal == ListPickerMode.Normal && newVal == ListPickerMode.Full)
{
// Picker Page is now showing
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
}
else if (oldVal == ListPickerMode.Full && newVal == ListPickerMode.Normal)
{
// PickerPage is now dismissed
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
}
}
return;
int elementSelectedIndex = picker.SelectedIndex - 1;
- ((IElementController)Element).SetValueFromRenderer(Picker.SelectedIndexProperty, elementSelectedIndex);
+ ElementController.SetValueFromRenderer(Picker.SelectedIndexProperty, elementSelectedIndex);
}
void UpdateAlignment()
var parent = current.Parent as NavigationPage;
if (parent != null)
{
- if (parent.InternalChildren[0] == current)
+ if (((IPageController)parent).InternalChildren[0] == current)
replaceWithRoot = true;
}
WButton _downButton;
WButton _upButton;
+ IElementController ElementController => Element as IElementController;
+
protected override void OnElementChanged(ElementChangedEventArgs<Stepper> e)
{
base.OnElementChanged(e);
void DownButtonOnClick(object sender, RoutedEventArgs routedEventArgs)
{
- ((IElementController)Element).SetValueFromRenderer(Stepper.ValueProperty, Math.Max(Element.Minimum, Element.Value - Element.Increment));
+ ElementController.SetValueFromRenderer(Stepper.ValueProperty, Math.Max(Element.Minimum, Element.Value - Element.Increment));
}
void UpButtonOnClick(object sender, RoutedEventArgs routedEventArgs)
{
- ((IElementController)Element).SetValueFromRenderer(Stepper.ValueProperty, Math.Min(Element.Maximum, Element.Value + Element.Increment));
+ ElementController.SetValueFromRenderer(Stepper.ValueProperty, Math.Min(Element.Maximum, Element.Value + Element.Increment));
}
void UpdateButtons()
{
readonly ToggleSwitchButton _toggleSwitch = new ToggleSwitchButton();
+ IElementController ElementController => Element as IElementController;
+
protected override void OnElementChanged(ElementChangedEventArgs<Switch> e)
{
base.OnElementChanged(e);
var container = new Border { Child = _toggleSwitch };
_toggleSwitch.IsChecked = Element.IsToggled;
- _toggleSwitch.Checked += (sender, args) => ((IElementController)Element).SetValueFromRenderer(Switch.IsToggledProperty, true);
- _toggleSwitch.Unchecked += (sender, args) => ((IElementController)Element).SetValueFromRenderer(Switch.IsToggledProperty, false);
+ _toggleSwitch.Checked += (sender, args) => ElementController.SetValueFromRenderer(Switch.IsToggledProperty, true);
+ _toggleSwitch.Unchecked += (sender, args) => ElementController.SetValueFromRenderer(Switch.IsToggledProperty, false);
_toggleSwitch.HorizontalAlignment = HorizontalAlignment.Right;
SetNativeControl(container);
if (pivotItem.ActualWidth > 0 && pivotItem.ActualHeight > 0)
{
var tab = (Page)DataContext;
- ((TabbedPage)tab.RealParent).ContainerArea = new Rectangle(0, 0, pivotItem.ActualWidth, pivotItem.ActualHeight);
+ ((IPageController)tab.RealParent).ContainerArea = new Rectangle(0, 0, pivotItem.ActualWidth, pivotItem.ActualHeight);
}
};
}
_page.PropertyChanged += OnPropertyChanged;
- Loaded += (sender, args) => _page.SendAppearing();
- Unloaded += (sender, args) => _page.SendDisappearing();
+ Loaded += (sender, args) => ((IPageController)_page).SendAppearing();
+ Unloaded += (sender, args) => ((IPageController)_page).SendDisappearing();
OnElementChanged(new VisualElementChangedEventArgs(_page, element));
}
_renderer = renderer;
}
+ IElementController ElementController => _renderer.Element as IElementController;
+
public void Load()
{
if (_loaded)
_renderer.Element.ChildRemoved += HandleChildRemoved;
_renderer.Element.ChildrenReordered += HandleChildrenReordered;
- foreach (Element child in _renderer.Element.LogicalChildren)
+ foreach (Element child in ElementController.LogicalChildren)
HandleChildAdded(_renderer.Element, new ElementEventArgs(child));
}
void EnsureZIndex()
{
- for (var index = 0; index < _renderer.Element.LogicalChildren.Count; index++)
+ for (var index = 0; index < ElementController.LogicalChildren.Count; index++)
{
- var child = (VisualElement)_renderer.Element.LogicalChildren[index];
+ var child = (VisualElement)ElementController.LogicalChildren[index];
IVisualElementRenderer r = Platform.GetRenderer(child);
if (r == null)
continue;
VisualElementTracker _tracker;
+ IElementController ElementController => Element as IElementController;
+
public TNativeElement Control { get; private set; }
public TElement Element { get; private set; }
Control.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height));
}
- for (var i = 0; i < Element.LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- var child = Element.LogicalChildren[i] as VisualElement;
+ var child = ElementController.LogicalChildren[i] as VisualElement;
if (child == null)
continue;
IVisualElementRenderer renderer = Platform.GetRenderer(child);
Element.IsInNativeLayout = true;
- for (var i = 0; i < Element.LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- var child = Element.LogicalChildren[i] as VisualElement;
+ var child = ElementController.LogicalChildren[i] as VisualElement;
if (child == null)
continue;
IVisualElementRenderer renderer = Platform.GetRenderer(child);
protected virtual void OnGotFocus(object sender, RoutedEventArgs args)
{
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
}
protected virtual void OnLostFocus(object sender, RoutedEventArgs args)
{
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
}
protected virtual void OnRegisterEffect(PlatformEffect effect)
if (ActualWidth > 0 && ActualHeight > 0)
{
var tab = ((Page)DataContext);
- ((TabbedPage)tab.RealParent).ContainerArea = new Rectangle(0, 0, ActualWidth, ActualHeight);
+ ((IPageController)tab.RealParent).ContainerArea = new Rectangle(0, 0, ActualWidth, ActualHeight);
}
};
}
if (Element == null)
return;
- Element.SendAppearing();
+ ((IPageController)Element).SendAppearing();
}
void OnUnloaded(object sender, RoutedEventArgs args)
if (Element == null)
return;
- Element.SendDisappearing();
+ ((IPageController)Element).SendDisappearing();
}
void OnTrackerUpdated(object sender, EventArgs e)
get { return (TabbedPage)Element; }
}
+ IPageController PageController => Element as IPageController;
+
protected VisualElementTracker<Page, Canvas> Tracker
{
get { return _tracker; }
return;
ShowTabs();
- Page.SendAppearing();
+ PageController.SendAppearing();
}
Windows.UI.Xaml.Controls.Page GetTopPage()
void OnUnloaded(object sender, RoutedEventArgs args)
{
RemoveTabs();
- if (Page != null)
- Page.SendDisappearing();
+ PageController?.SendDisappearing();
}
}
}
\ No newline at end of file
get { return Element; }
}
+ IPageController PageController => Element as IPageController;
+
public event EventHandler<VisualElementChangedEventArgs> ElementChanged;
public SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
if (oldPage != null)
{
- oldPage.SendDisappearing();
+ ((IPageController)oldPage).SendDisappearing();
((INotifyCollectionChanged)oldPage.Children).CollectionChanged -= OnChildrenChanged;
oldPage.PropertyChanged -= OnElementPropertyChanged;
}
newPage.PropertyChanged += OnElementPropertyChanged;
UpdateCurrentPage();
- newPage.SendAppearing();
+ ((IPageController)newPage).SendAppearing();
}
OnElementChanged(new ElementChangedEventArgs<CarouselPage>(oldPage, newPage));
}
_disposed = true;
- Element?.SendDisappearing();
+ PageController?.SendDisappearing();
SetElement(null);
}
void OnLoaded(object sender, RoutedEventArgs e)
{
- Element?.SendAppearing();
+ PageController?.SendAppearing();
}
void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
ContentPage currentPage = Element.CurrentPage;
if (currentPage == page)
return;
- currentPage?.SendDisappearing();
+ ((IPageController)currentPage)?.SendDisappearing();
Element.CurrentPage = page;
- page?.SendAppearing();
+ ((IPageController)page)?.SendAppearing();
}
void OnUnloaded(object sender, RoutedEventArgs e)
{
- Element?.SendDisappearing();
+ PageController?.SendDisappearing();
}
void UpdateCurrentPage()
get { return Device.Idiom == TargetIdiom.Phone; }
}
+ IPageController PageController => Element as IPageController;
+
public void Dispose()
{
Dispose(true);
void OnLoaded(object sender, RoutedEventArgs args)
{
- if (Element == null)
- return;
-
- Element.SendAppearing();
+ PageController?.SendAppearing();
}
void OnNativeSizeChanged(object sender, SizeChangedEventArgs e)
void OnUnloaded(object sender, RoutedEventArgs args)
{
- if (Element == null)
- return;
-
- Element.SendDisappearing();
+ PageController?.SendDisappearing();
}
void OnUserClosedPopover(object sender, EventArgs e)
}
}
+ IPageController PageController => Element as IPageController;
+
bool ITitleProvider.ShowTitle
{
get { return _showTitle; }
((INavigationPageController)oldElement).PushRequested -= OnPushRequested;
((INavigationPageController)oldElement).PopRequested -= OnPopRequested;
((INavigationPageController)oldElement).PopToRootRequested -= OnPopToRootRequested;
- oldElement.InternalChildren.CollectionChanged -= OnChildrenChanged;
+ ((IPageController)oldElement).InternalChildren.CollectionChanged -= OnChildrenChanged;
oldElement.PropertyChanged -= OnElementPropertyChanged;
}
((INavigationPageController)Element).PushRequested += OnPushRequested;
((INavigationPageController)Element).PopRequested += OnPopRequested;
((INavigationPageController)Element).PopToRootRequested += OnPopToRootRequested;
- Element.InternalChildren.CollectionChanged += OnChildrenChanged;
+ PageController.InternalChildren.CollectionChanged += OnChildrenChanged;
if (!string.IsNullOrEmpty(Element.AutomationId))
_container.SetValue(AutomationProperties.AutomationIdProperty, Element.AutomationId);
{
if (!disposing || _disposed)
return;
- Element?.SendDisappearing();
+ PageController?.SendDisappearing();
_disposed = true;
_container.PointerPressed -= OnPointerPressed;
#if WINDOWS_UWP
_navManager = SystemNavigationManager.GetForCurrentView();
#endif
- Element.SendAppearing();
+ PageController.SendAppearing();
UpdateBackButton();
UpdateTitleOnParents();
}
void OnPopRequested(object sender, NavigationRequestedEventArgs e)
{
- var newCurrent = (Page)Element.InternalChildren[Element.InternalChildren.Count - 2];
+ var newCurrent = (Page)PageController.InternalChildren[PageController.InternalChildren.Count - 2];
SetPage(newCurrent, e.Animated, true);
}
void OnUnloaded(object sender, RoutedEventArgs args)
{
- if (Element == null)
- return;
-
- Element.SendDisappearing();
+ PageController?.SendDisappearing();
}
void PushExistingNavigationStack()
void UpdateBackButton()
{
- bool showBackButton = Element.InternalChildren.Count > 1 && NavigationPage.GetHasBackButton(_currentPage);
+ bool showBackButton = PageController.InternalChildren.Count > 1 && NavigationPage.GetHasBackButton(_currentPage);
_container.ShowBackButton = showBackButton;
#if WINDOWS_UWP
void UpdateContainerArea()
{
- Element.ContainerArea = new Rectangle(0, 0, _container.ContentWidth, _container.ContentHeight);
+ PageController.ContainerArea = new Rectangle(0, 0, _container.ContentWidth, _container.ContentHeight);
}
void UpdateNavigationBarBackground()
bool _loaded;
+ IPageController PageController => Element as IPageController;
+
protected override void Dispose(bool disposing)
{
if (!disposing || _disposed)
if (Element != null)
{
- ReadOnlyCollection<Element> children = Element.LogicalChildren;
+ ReadOnlyCollection<Element> children = ((IElementController)Element).LogicalChildren;
for (var i = 0; i < children.Count; i++)
{
var visualChild = children[i] as VisualElement;
visualChild?.Cleanup();
}
- Element?.SendDisappearing();
+ PageController?.SendDisappearing();
}
base.Dispose();
{
base.OnElementChanged(e);
- if (e.OldElement != null)
- {
- e.OldElement.SendDisappearing();
- }
+ ((IPageController)e.OldElement)?.SendDisappearing();
if (e.NewElement != null)
{
}
if (_loaded)
- e.NewElement.SendAppearing();
+ ((IPageController)e.NewElement).SendAppearing();
}
}
return;
}
_loaded = true;
- Element?.SendAppearing();
+ PageController?.SendAppearing();
}
void OnUnloaded(object sender, RoutedEventArgs args)
{
_loaded = false;
- Element?.SendDisappearing();
+ PageController?.SendDisappearing();
}
}
}
\ No newline at end of file
var wrapperAwareRenderer = currentRenderer as IWrapperAware;
wrapperAwareRenderer?.NotifyWrapped();
- foreach (Element child in currentView.LogicalChildren)
+ foreach (Element child in ((IElementController)currentView).LogicalChildren)
{
var childView = child as View;
if (childView == null)
_columnSpan = columnSpan;
}
+ IElementController ElementController => _renderer.Element as IElementController;
+
public void Dispose()
{
if (_disposed)
_renderer.Element.ChildAdded += OnChildAdded;
_renderer.Element.ChildRemoved += OnChildRemoved;
- ReadOnlyCollection<Element> children = _renderer.Element.LogicalChildren;
+ ReadOnlyCollection<Element> children = ElementController.LogicalChildren;
for (var i = 0; i < children.Count; i++)
{
OnChildAdded(_renderer.Element, new ElementEventArgs(children[i]));
void EnsureZIndex()
{
- if (_renderer.Element.LogicalChildren.Count == 0)
+ if (ElementController.LogicalChildren.Count == 0)
return;
- for (var z = 0; z < _renderer.Element.LogicalChildren.Count; z++)
+ for (var z = 0; z < ElementController.LogicalChildren.Count; z++)
{
- var child = _renderer.Element.LogicalChildren[z] as VisualElement;
+ var child = ElementController.LogicalChildren[z] as VisualElement;
if (child == null)
continue;
protected bool AutoTrack { get; set; } = true;
+ IElementController ElementController => Element as IElementController;
+
protected VisualElementTracker<TElement, TNativeElement> Tracker
{
get { return _tracker; }
Control.Arrange(new Rect(0, 0, finalSize.Width, finalSize.Height));
}
- for (var i = 0; i < Element.LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- var child = Element.LogicalChildren[i] as VisualElement;
+ var child = ElementController.LogicalChildren[i] as VisualElement;
if (child == null)
continue;
IVisualElementRenderer renderer = Platform.GetRenderer(child);
Element.IsInNativeLayout = true;
- for (var i = 0; i < Element.LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- var child = Element.LogicalChildren[i] as VisualElement;
+ var child = ElementController.LogicalChildren[i] as VisualElement;
if (child == null)
continue;
IVisualElementRenderer renderer = Platform.GetRenderer(child);
var sameChildrenTypes = true;
- var oldChildren = _oldElement.LogicalChildren;
- var newChildren = newElement.LogicalChildren;
+ var oldChildren = ((IElementController)_oldElement).LogicalChildren;
+ var newChildren = ((IElementController)newElement).LogicalChildren;
if (oldChildren.Count == newChildren.Count)
{
void FillChildrenWithRenderers(VisualElement element)
{
- foreach (var logicalChild in element.LogicalChildren)
+ foreach (var logicalChild in ((IElementController)element).LogicalChildren)
{
var child = logicalChild as VisualElement;
if (child != null)
void UpdateRenderers(Element newElement)
{
- if (newElement.LogicalChildren.Count == 0)
+ var newElementController = (IElementController)newElement;
+
+ if (newElementController.LogicalChildren.Count == 0)
return;
var subviews = _parent.NativeView.Subviews;
continue;
var x = (int)childRenderer.NativeView.Layer.ZPosition / 1000;
- var element = newElement.LogicalChildren[x] as VisualElement;
+ var element = newElementController.LogicalChildren[x] as VisualElement;
if (element == null)
continue;
WantsFullScreenLayout = true;
}
+ IElementController ElementController => Element as IElementController;
+
protected CarouselPage Carousel
{
get { return (CarouselPage)Element; }
}
+ IPageController PageController => (IPageController)Element;
+
protected int SelectedIndex
{
get { return (int)(_scrollView.ContentOffset.X / _scrollView.Frame.Width); }
return;
_appeared = true;
- Carousel.SendAppearing();
+ PageController.SendAppearing();
}
public override void ViewDidDisappear(bool animated)
return;
_appeared = false;
- Carousel.SendDisappearing();
+ PageController.SendDisappearing();
}
public override void ViewDidLayoutSubviews()
View.Add(_scrollView);
- for (var i = 0; i < Element.LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- Element element = Element.LogicalChildren[i];
+ Element element = ElementController.LogicalChildren[i];
var child = element as ContentPage;
if (child != null)
InsertPage(child, i);
if (_appeared)
{
_appeared = false;
- Carousel.SendDisappearing();
+ PageController?.SendDisappearing();
}
if (_events != null)
void OnDecelerationEnded(object sender, EventArgs eventArgs)
{
- if (_ignoreNativeScrolling || SelectedIndex >= Element.LogicalChildren.Count)
+ if (_ignoreNativeScrolling || SelectedIndex >= ElementController.LogicalChildren.Count)
return;
- Carousel.CurrentPage = (ContentPage)Element.LogicalChildren[SelectedIndex];
+ Carousel.CurrentPage = (ContentPage)ElementController.LogicalChildren[SelectedIndex];
}
void OnPagesChanged(object sender, NotifyCollectionChangedEventArgs e)
{
Clear();
- for (var i = 0; i < Element.LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- Element element = Element.LogicalChildren[i];
+ Element element = ElementController.LogicalChildren[i];
var child = element as ContentPage;
if (child != null)
InsertPage(child, i);
UIDatePicker _picker;
UIColor _defaultTextColor;
+ IElementController ElementController => Element as IElementController;
+
protected override void OnElementChanged(ElementChangedEventArgs<DatePicker> e)
{
base.OnElementChanged(e);
void HandleValueChanged(object sender, EventArgs e)
{
- if (Element != null)
- ((IElementController)Element).SetValueFromRenderer(DatePicker.DateProperty, _picker.Date.ToDateTime().Date);
+ ElementController?.SetValueFromRenderer(DatePicker.DateProperty, _picker.Date.ToDateTime().Date);
}
void OnEnded(object sender, EventArgs eventArgs)
{
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
}
void OnStarted(object sender, EventArgs eventArgs)
{
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
}
void UpdateDateFromModel(bool animate)
{
UIToolbar _accessoryView;
+ IElementController ElementController => Element as IElementController;
+
public override SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
{
if (!Forms.IsiOS7OrNewer)
void HandleChanged(object sender, EventArgs e)
{
- ((IElementController)Element).SetValueFromRenderer(Editor.TextProperty, Control.Text);
+ ElementController.SetValueFromRenderer(Editor.TextProperty, Control.Text);
}
void OnEnded(object sender, EventArgs eventArgs)
void OnStarted(object sender, EventArgs eventArgs)
{
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
}
void UpdateEditable()
Frame = new RectangleF(0, 20, 320, 40);
}
+ IElementController ElementController => Element as IElementController;
+
protected override void Dispose(bool disposing)
{
if (disposing)
void OnEditingBegan(object sender, EventArgs e)
{
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
}
void OnEditingChanged(object sender, EventArgs eventArgs)
{
- ((IElementController)Element).SetValueFromRenderer(Entry.TextProperty, Control.Text);
+ ElementController.SetValueFromRenderer(Entry.TextProperty, Control.Text);
}
void OnEditingEnded(object sender, EventArgs e)
{
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
}
bool OnShouldReturn(UITextField view)
{
bool _isDisposed;
+ IElementController ElementController => Element as IElementController;
+
protected override void Dispose(bool disposing)
{
if (_isDisposed)
Page Current { get; set; }
+ IPageController PageController => Element as IPageController;
+
public VisualElement Element { get; private set; }
public event EventHandler<VisualElementChangedEventArgs> ElementChanged;
if (!_appeared)
{
_appeared = true;
- ((NavigationPage)Element)?.SendAppearing();
+ PageController?.SendAppearing();
}
base.ViewDidAppear(animated);
return;
_appeared = false;
- ((NavigationPage)Element).SendDisappearing();
+ PageController.SendDisappearing();
}
public override void ViewDidLayoutSubviews()
double trueBottom = toolbar.Hidden ? toolbarY : toolbar.Frame.Bottom;
var modelSize = _queuedSize.IsZero ? Element.Bounds.Size : _queuedSize;
- ((NavigationPage)Element).ContainerArea =
+ PageController.ContainerArea =
new Rectangle(0, toolbar.Hidden ? 0 : toolbar.Frame.Height, modelSize.Width, modelSize.Height - trueBottom);
if (!_queuedSize.IsZero)
base.Dispose(disposing);
if (_appeared)
{
- ((Page)Element).SendDisappearing();
+ PageController.SendDisappearing();
_appeared = false;
}
{
if (disposing)
{
- Child.SendDisappearing();
+ ((IPageController)Child).SendDisappearing();
Child = null;
_tracker.Target = null;
_tracker.CollectionChanged -= TrackerOnCollectionChanged;
VisualElementPackager _packager;
VisualElementTracker _tracker;
+ IPageController PageController => Element as IPageController;
+
public PageRenderer()
{
if (!Forms.IsiOS7OrNewer)
return;
_appeared = true;
- ((Page)Element).SendAppearing();
+ PageController.SendAppearing();
}
public override void ViewDidDisappear(bool animated)
return;
_appeared = false;
- ((Page)Element).SendDisappearing();
+ PageController.SendDisappearing();
}
public override void ViewDidLoad()
Element.PropertyChanged -= OnHandlePropertyChanged;
Platform.SetRenderer(Element, null);
if (_appeared)
- ((Page)Element).SendDisappearing();
+ PageController.SendDisappearing();
_appeared = false;
VisualElementTracker _tracker;
+ IPageController PageController => Element as IPageController;
+
public PhoneMasterDetailRenderer()
{
if (!Forms.IsiOS7OrNewer)
public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
- ((Page)Element).SendAppearing();
+ PageController.SendAppearing();
}
public override void ViewDidDisappear(bool animated)
{
base.ViewDidDisappear(animated);
- ((Page)Element).SendDisappearing();
+ PageController.SendDisappearing();
}
public override void ViewDidLayoutSubviews()
EmptyContainers();
- ((Page)Element).SendDisappearing();
+ PageController.SendDisappearing();
_disposed = true;
}
UIPickerView _picker;
UIColor _defaultTextColor;
+ IElementController ElementController => Element as IElementController;
+
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
if (e.OldElement != null)
void OnEnded(object sender, EventArgs eventArgs)
{
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
}
void OnStarted(object sender, EventArgs eventArgs)
{
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
}
void RowsCollectionChanged(object sender, EventArgs e)
if (Element != null)
{
var oldText = Control.Text;
- ((IElementController)Element).SetValueFromRenderer(Picker.SelectedIndexProperty, s.SelectedIndex);
+ ElementController.SetValueFromRenderer(Picker.SelectedIndexProperty, s.SelectedIndex);
Control.Text = s.SelectedItem;
UpdatePickerNativeSize(oldText);
}
UIColor _defaultTintColor;
UITextField _textField;
+ IElementController ElementController => Element as IElementController;
+
protected override void Dispose(bool disposing)
{
if (disposing)
void OnCancelClicked(object sender, EventArgs args)
{
- ((IElementController)Element).SetValueFromRenderer(SearchBar.TextProperty, null);
+ ElementController.SetValueFromRenderer(SearchBar.TextProperty, null);
Control.ResignFirstResponder();
}
void OnEditingEnded(object sender, EventArgs e)
{
- if (Element != null)
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
+ ElementController?.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
}
void OnEditingStarted(object sender, EventArgs e)
{
- if (Element != null)
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
+ ElementController?.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
}
void OnSearchButtonClicked(object sender, EventArgs e)
void OnTextChanged(object sender, UISearchBarTextChangedEventArgs a)
{
- ((IElementController)Element).SetValueFromRenderer(SearchBar.TextProperty, Control.Text);
+ ElementController.SetValueFromRenderer(SearchBar.TextProperty, Control.Text);
}
void UpdateAlignment()
bool _loaded;
Size _queuedSize;
+ IPageController PageController => Element as IPageController;
+ IElementController ElementController => Element as IElementController;
+
public override UIViewController SelectedViewController
{
get { return base.SelectedViewController; }
public override void ViewDidAppear(bool animated)
{
- ((TabbedPage)Element).SendAppearing();
+ PageController.SendAppearing();
base.ViewDidAppear(animated);
}
public override void ViewDidDisappear(bool animated)
{
base.ViewDidDisappear(animated);
- ((TabbedPage)Element).SendDisappearing();
+ PageController.SendDisappearing();
}
public override void ViewDidLayoutSubviews()
var frame = View.Frame;
var tabBarFrame = TabBar.Frame;
- ((TabbedPage)Element).ContainerArea = new Rectangle(0, 0, frame.Width, frame.Height - tabBarFrame.Height);
+ PageController.ContainerArea = new Rectangle(0, 0, frame.Width, frame.Height - tabBarFrame.Height);
if (!_queuedSize.IsZero)
{
{
if (disposing)
{
- ((TabbedPage)Element).SendDisappearing();
+ PageController.SendDisappearing();
Tabbed.PropertyChanged -= OnPropertyChanged;
Tabbed.PagesChanged -= OnPagesChanged;
FinishedCustomizingViewControllers -= HandleFinishedCustomizingViewControllers;
void SetControllers()
{
var list = new List<UIViewController>();
- for (var i = 0; i < Element.LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- var child = Element.LogicalChildren[i];
+ var child = ElementController.LogicalChildren[i];
var v = child as VisualElement;
if (v == null)
continue;
var originalIndex = -1;
if (int.TryParse(viewControllers[i].TabBarItem.Tag.ToString(), out originalIndex))
{
- var page = (Page)Tabbed.InternalChildren[originalIndex];
+ var page = (TabbedPage)((IPageController)Tabbed).InternalChildren[originalIndex];
TabbedPage.SetIndex(page, i);
}
}
void UpdateCurrentPage()
{
- ((TabbedPage)Element).CurrentPage = SelectedIndex >= 0 && SelectedIndex < Tabbed.InternalChildren.Count ? Tabbed.GetPageByIndex((int)SelectedIndex) : null;
+ var count = ((IPageController)Tabbed).InternalChildren.Count;
+ ((TabbedPage)Element).CurrentPage = SelectedIndex >= 0 && SelectedIndex < count ? Tabbed.GetPageByIndex((int)SelectedIndex) : null;
}
void IEffectControlProvider.RegisterEffect(Effect effect)
VisualElementTracker _tracker;
+ IPageController PageController => Element as IPageController;
+ IElementController ElementController => Element as IElementController;
+
protected MasterDetailPage MasterDetailPage
{
get { return _masterDetailPage ?? (_masterDetailPage = (MasterDetailPage)Element); }
{
if (Element != null)
{
- ((Page)Element).SendDisappearing();
+ PageController.SendDisappearing();
Element.PropertyChanged -= HandlePropertyChanged;
Element = null;
}
public override void ViewDidAppear(bool animated)
{
- ((Page)Element).SendAppearing();
+ PageController.SendAppearing();
base.ViewDidAppear(animated);
ToggleMaster();
}
public override void ViewDidDisappear(bool animated)
{
base.ViewDidDisappear(animated);
- ((Page)Element).SendDisappearing();
+ PageController.SendDisappearing();
}
public override void ViewDidLayoutSubviews()
{
_masterVisible = true;
if (MasterDetailPageController.CanChangeIsPresented)
- ((IElementController)Element).SetValueFromRenderer(MasterDetailPage.IsPresentedProperty, true);
+ ElementController.SetValueFromRenderer(MasterDetailPage.IsPresentedProperty, true);
}
void MasterControllerWillDisappear(object sender, EventArgs e)
{
_masterVisible = false;
if (MasterDetailPageController.CanChangeIsPresented)
- ((IElementController)Element).SetValueFromRenderer(MasterDetailPage.IsPresentedProperty, false);
+ ElementController.SetValueFromRenderer(MasterDetailPage.IsPresentedProperty, false);
}
void PerformButtonSelector()
UIDatePicker _picker;
UIColor _defaultTextColor;
+ IElementController ElementController => Element as IElementController;
+
protected override void Dispose(bool disposing)
{
if (disposing)
void OnEnded(object sender, EventArgs eventArgs)
{
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
}
void OnStarted(object sender, EventArgs eventArgs)
{
- ((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
+ ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
}
void OnValueChanged(object sender, EventArgs e)
{
- ((IElementController)Element).SetValueFromRenderer(TimePicker.TimeProperty, _picker.Date.ToDateTime() - new DateTime(1, 1, 1));
+ ElementController.SetValueFromRenderer(TimePicker.TimeProperty, _picker.Date.ToDateTime() - new DateTime(1, 1, 1));
}
void UpdateTextColor()
bool _isDisposed;
+ IElementController ElementController => Renderer.Element as IElementController;
+
public VisualElementPackager(IVisualElementRenderer renderer)
{
if (renderer == null)
public void Load()
{
- for (var i = 0; i < Renderer.Element.LogicalChildren.Count; i++)
+ for (var i = 0; i < ElementController.LogicalChildren.Count; i++)
{
- var child = Renderer.Element.LogicalChildren[i] as VisualElement;
+ var child = ElementController.LogicalChildren[i] as VisualElement;
if (child != null)
OnChildAdded(child);
}
void EnsureChildrenOrder()
{
- if (Renderer.Element.LogicalChildren.Count == 0)
+ if (ElementController.LogicalChildren.Count == 0)
return;
- for (var z = 0; z < Renderer.Element.LogicalChildren.Count; z++)
+ for (var z = 0; z < ElementController.LogicalChildren.Count; z++)
{
- var child = Renderer.Element.LogicalChildren[z] as VisualElement;
+ var child = ElementController.LogicalChildren[z] as VisualElement;
if (child == null)
continue;
var childRenderer = Platform.GetRenderer(child);
}
else
{
- for (var i = 0; i < oldElement.LogicalChildren.Count; i++)
+ var elementController = ((IElementController)oldElement);
+
+ for (var i = 0; i < elementController.LogicalChildren.Count; i++)
{
- var child = oldElement.LogicalChildren[i] as VisualElement;
+ var child = elementController.LogicalChildren[i] as VisualElement;
if (child != null)
OnChildRemoved(child);
}
<remarks>To be added.</remarks>
</Docs>
</Member>
+ <Member MemberName="Xamarin.Forms.IElementController.LogicalChildren">
+ <MemberSignature Language="C#" Value="System.Collections.ObjectModel.ReadOnlyCollection<Xamarin.Forms.Element> Xamarin.Forms.IElementController.LogicalChildren { get; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance class System.Collections.ObjectModel.ReadOnlyCollection`1<class Xamarin.Forms.Element> Xamarin.Forms.IElementController.LogicalChildren" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Collections.ObjectModel.ReadOnlyCollection<Xamarin.Forms.Element></ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <value>To be added.</value>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="Xamarin.Forms.IElementController.SetValueFromRenderer">
<MemberSignature Language="C#" Value="void IElementController.SetValueFromRenderer (Xamarin.Forms.BindableProperty property, object value);" />
<MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance void Xamarin.Forms.IElementController.SetValueFromRenderer(class Xamarin.Forms.BindableProperty property, object value) cil managed" />
<remarks>To be added.</remarks>
</Docs>
</Member>
+ <Member MemberName="LogicalChildren">
+ <MemberSignature Language="C#" Value="public System.Collections.ObjectModel.ReadOnlyCollection<Xamarin.Forms.Element> LogicalChildren { get; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance class System.Collections.ObjectModel.ReadOnlyCollection`1<class Xamarin.Forms.Element> LogicalChildren" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Collections.ObjectModel.ReadOnlyCollection<Xamarin.Forms.Element></ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <value>To be added.</value>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="SetValueFromRenderer">
<MemberSignature Language="C#" Value="public void SetValueFromRenderer (Xamarin.Forms.BindableProperty property, object value);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void SetValueFromRenderer(class Xamarin.Forms.BindableProperty property, object value) cil managed" />
--- /dev/null
+<Type Name="IPageController" FullName="Xamarin.Forms.IPageController">
+ <TypeSignature Language="C#" Value="public interface IPageController" />
+ <TypeSignature Language="ILAsm" Value=".class public interface auto ansi abstract IPageController" />
+ <AssemblyInfo>
+ <AssemblyName>Xamarin.Forms.Core</AssemblyName>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <Interfaces />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ <Members>
+ <Member MemberName="ContainerArea">
+ <MemberSignature Language="C#" Value="public Xamarin.Forms.Rectangle ContainerArea { get; set; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance valuetype Xamarin.Forms.Rectangle ContainerArea" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Xamarin.Forms.Rectangle</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <value>To be added.</value>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="IgnoresContainerArea">
+ <MemberSignature Language="C#" Value="public bool IgnoresContainerArea { get; set; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance bool IgnoresContainerArea" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Boolean</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <value>To be added.</value>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="InternalChildren">
+ <MemberSignature Language="C#" Value="public System.Collections.ObjectModel.ObservableCollection<Xamarin.Forms.Element> InternalChildren { get; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance class System.Collections.ObjectModel.ObservableCollection`1<class Xamarin.Forms.Element> InternalChildren" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Collections.ObjectModel.ObservableCollection<Xamarin.Forms.Element></ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <value>To be added.</value>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="SendAppearing">
+ <MemberSignature Language="C#" Value="public void SendAppearing ();" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void SendAppearing() cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Void</ReturnType>
+ </ReturnValue>
+ <Parameters />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="SendDisappearing">
+ <MemberSignature Language="C#" Value="public void SendDisappearing ();" />
+ <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void SendDisappearing() cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Void</ReturnType>
+ </ReturnValue>
+ <Parameters />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ </Members>
+</Type>
<Type Name="Page" FullName="Xamarin.Forms.Page">
- <TypeSignature Language="C#" Value="public class Page : Xamarin.Forms.VisualElement, Xamarin.Forms.ILayout" />
- <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit Page extends Xamarin.Forms.VisualElement implements class Xamarin.Forms.ILayout" />
+ <TypeSignature Language="C#" Value="public class Page : Xamarin.Forms.VisualElement, Xamarin.Forms.ILayout, Xamarin.Forms.IPageController" />
+ <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit Page extends Xamarin.Forms.VisualElement implements class Xamarin.Forms.ILayout, class Xamarin.Forms.IPageController" />
<AssemblyInfo>
<AssemblyName>Xamarin.Forms.Core</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Interface>
<InterfaceName>Xamarin.Forms.ILayout</InterfaceName>
</Interface>
+ <Interface>
+ <InterfaceName>Xamarin.Forms.IPageController</InterfaceName>
+ </Interface>
</Interfaces>
<Attributes>
<Attribute>
<remarks>To be added.</remarks>
</Docs>
</Member>
+ <Member MemberName="ActionSheetSignalName">
+ <MemberSignature Language="C#" Value="public const string ActionSheetSignalName;" />
+ <MemberSignature Language="ILAsm" Value=".field public static literal string ActionSheetSignalName" />
+ <MemberType>Field</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.String</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="AlertSignalName">
+ <MemberSignature Language="C#" Value="public const string AlertSignalName;" />
+ <MemberSignature Language="ILAsm" Value=".field public static literal string AlertSignalName" />
+ <MemberType>Field</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.String</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="Appearing">
<MemberSignature Language="C#" Value="public event EventHandler Appearing;" />
<MemberSignature Language="ILAsm" Value=".event class System.EventHandler Appearing" />
<remarks>To be added.</remarks>
</Docs>
</Member>
+ <Member MemberName="BusySetSignalName">
+ <MemberSignature Language="C#" Value="public const string BusySetSignalName;" />
+ <MemberSignature Language="ILAsm" Value=".field public static literal string BusySetSignalName" />
+ <MemberType>Field</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.String</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="Disappearing">
<MemberSignature Language="C#" Value="public event EventHandler Disappearing;" />
<MemberSignature Language="ILAsm" Value=".event class System.EventHandler Disappearing" />
<remarks>To be added.</remarks>
</Docs>
</Member>
+ <Member MemberName="Xamarin.Forms.IPageController.ContainerArea">
+ <MemberSignature Language="C#" Value="Xamarin.Forms.Rectangle Xamarin.Forms.IPageController.ContainerArea { get; set; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance valuetype Xamarin.Forms.Rectangle Xamarin.Forms.IPageController.ContainerArea" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>Xamarin.Forms.Rectangle</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <value>To be added.</value>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Xamarin.Forms.IPageController.IgnoresContainerArea">
+ <MemberSignature Language="C#" Value="bool Xamarin.Forms.IPageController.IgnoresContainerArea { get; set; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance bool Xamarin.Forms.IPageController.IgnoresContainerArea" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Boolean</ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <value>To be added.</value>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Xamarin.Forms.IPageController.InternalChildren">
+ <MemberSignature Language="C#" Value="System.Collections.ObjectModel.ObservableCollection<Xamarin.Forms.Element> Xamarin.Forms.IPageController.InternalChildren { get; }" />
+ <MemberSignature Language="ILAsm" Value=".property instance class System.Collections.ObjectModel.ObservableCollection`1<class Xamarin.Forms.Element> Xamarin.Forms.IPageController.InternalChildren" />
+ <MemberType>Property</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Collections.ObjectModel.ObservableCollection<Xamarin.Forms.Element></ReturnType>
+ </ReturnValue>
+ <Docs>
+ <summary>To be added.</summary>
+ <value>To be added.</value>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Xamarin.Forms.IPageController.SendAppearing">
+ <MemberSignature Language="C#" Value="void IPageController.SendAppearing ();" />
+ <MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance void Xamarin.Forms.IPageController.SendAppearing() cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Void</ReturnType>
+ </ReturnValue>
+ <Parameters />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
+ <Member MemberName="Xamarin.Forms.IPageController.SendDisappearing">
+ <MemberSignature Language="C#" Value="void IPageController.SendDisappearing ();" />
+ <MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance void Xamarin.Forms.IPageController.SendDisappearing() cil managed" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>2.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Void</ReturnType>
+ </ReturnValue>
+ <Parameters />
+ <Docs>
+ <summary>To be added.</summary>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
</Members>
</Type>