First pass at navigation with MasterDetail
This commit is contained in:
38
Aurora/Frontend/Components/ContentPresenter.cs
Normal file
38
Aurora/Frontend/Components/ContentPresenter.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Aurora.Frontend.Components
|
||||
{
|
||||
public class ContentPresenter : ContentView
|
||||
{
|
||||
public static readonly BindableProperty ItemTemplateProperty = BindableProperty.Create("ItemTemplate", typeof(DataTemplate), typeof(ContentPresenter), null, propertyChanged: OnItemTemplateChanged);
|
||||
|
||||
private static void OnItemTemplateChanged(BindableObject bindable, object oldvalue, object newvalue)
|
||||
{
|
||||
var cp = (ContentPresenter)bindable;
|
||||
|
||||
var template = cp.ItemTemplate;
|
||||
if (template != null)
|
||||
{
|
||||
var content = (View)template.CreateContent();
|
||||
cp.Content = content;
|
||||
}
|
||||
else
|
||||
{
|
||||
cp.Content = null;
|
||||
}
|
||||
}
|
||||
|
||||
public DataTemplate ItemTemplate
|
||||
{
|
||||
get
|
||||
{
|
||||
return (DataTemplate)GetValue(ItemTemplateProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(ItemTemplateProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user