Reorganization
This commit is contained in:
59
Aurora/Design/Views/MainView/MainView.xaml.cs
Normal file
59
Aurora/Design/Views/MainView/MainView.xaml.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Aurora.Design.Components.NavigationMenu;
|
||||
using Aurora.Design.Views.MainView;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace Aurora.Design.Views.Main
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class MainView : MasterDetailPage
|
||||
{
|
||||
public MainView()
|
||||
{
|
||||
InitializeComponent();
|
||||
BindingContext = new MainViewModel();
|
||||
MasterPage.ListView.ItemSelected += ListView_ItemSelected;
|
||||
|
||||
Appearing += OnAppearing;
|
||||
}
|
||||
~MainView()
|
||||
{
|
||||
Appearing -= OnAppearing;
|
||||
}
|
||||
|
||||
private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
|
||||
{
|
||||
var item = e.SelectedItem as NavigationItem;
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
var view = (View)Activator.CreateInstance(item.TargetType);
|
||||
|
||||
ContentPresenter viewContent = (ContentPresenter)ContentPage.Content.FindByName("ViewContent");
|
||||
viewContent.Content = view;
|
||||
|
||||
MasterPage.ListView.SelectedItem = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for page appearing.
|
||||
/// </summary>
|
||||
/// <param name="sender">The object that fired the event.</param>
|
||||
/// <param name="args">The event arguments</param>
|
||||
private void OnAppearing(object sender, EventArgs args)
|
||||
{
|
||||
//Set initial view from first item in list
|
||||
ObservableCollection<NavigationGroupItem> screenList = (ObservableCollection<NavigationGroupItem>)MasterPage.ListView.ItemsSource;
|
||||
var view = (View)Activator.CreateInstance(screenList.FirstOrDefault().FirstOrDefault().TargetType);
|
||||
|
||||
ContentPresenter viewContent = (ContentPresenter)ContentPage.Content.FindByName("ViewContent");
|
||||
viewContent.Content = view;
|
||||
|
||||
MasterPage.ListView.SelectedItem = screenList.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user