demo-xf-app-1a/MobileApp1/Views/MainPage.xaml.cs

47 lines
1.3 KiB
C#
Raw Normal View History

2021-08-02 21:49:48 +00:00
using MobileApp1.Models;
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace MobileApp1.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainPage : FlyoutPage
{
public MainPage()
{
InitializeComponent();
flyoutPage.listView.ItemSelected += listView1_OnItemSelected;
}
//private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
//{
// var item = e.SelectedItem as MainPageFlyoutMenuItem;
// if (item == null)
// return;
// var page = (Page)Activator.CreateInstance(item.TargetType);
// page.Title = item.Title;
// Detail = new NavigationPage(page);
// IsPresented = false;
// FlyoutPage.ListView.SelectedItem = null;
//}
private void listView1_OnItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var item = e.SelectedItem as FlyoutPageItem;
if (item == null)
{
return;
}
Detail = new NavigationPage((Page)Activator.CreateInstance(item.TargetType));
flyoutPage.listView.SelectedItem = null;
IsPresented = false;
}
}
}