using MobileApp1.Models; using System.Threading.Tasks; using Xamarin.Forms; using Xamarin.Forms.Xaml; namespace MobileApp1.Views { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class FlyoutMenuPage : ContentPage { public FlyoutMenuPage() { InitializeComponent(); listView1.ItemSelected += listView1_ItemSelected; } private async void listView1_ItemSelected(object sender, SelectedItemChangedEventArgs e) { await Task.Run(() => { var item = e.SelectedItem as FlyoutPageItem; if (item == null) { return; } MainPage mainPage = ContentPageHelper.GetMainPage(this); if (mainPage == null) { return; } ContentPageHelper.SetDetailPage(this, item.TargetType); Device.BeginInvokeOnMainThread(() => { listView1.SelectedItem = null; mainPage.IsPresented = false; }); }); } } }