Skip to content

Instantly share code, notes, and snippets.

@ionoy
Created June 5, 2018 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ionoy/80fd93d5d6c027c3fb5e0362be37fefc to your computer and use it in GitHub Desktop.
Save ionoy/80fd93d5d6c027c3fb5e0362be37fefc to your computer and use it in GitHub Desktop.
class MyView : View, IElementController
{
public static BindableProperty HostedPageProperty = BindableProperty.Create("HostedPage", typeof(Page), typeof(MyView), propertyChanged: OnHostedPageChanged);
ReadOnlyCollection<Element> _logicalChildrenInner = new ReadOnlyCollection<Element>(new List<Element>());
ReadOnlyCollection<Element> IElementController.LogicalChildren => _logicalChildrenInner;
public void SetHostedPage(Page page)
{
_logicalChildrenInner = new ReadOnlyCollection<Element>(new List<Element>(new[] { page } ));
}
private static void OnHostedPageChanged(BindableObject bindable, object oldValue, object newValue)
{
var myView = (MyView)bindable;
myView.SetHostedPage((Page)newValue);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment