demo-xf-app-1a/MobileApp1/Views/FlyoutMenuPage.xaml.cs
2021-08-03 17:43:16 +01:00

47 lines
1.2 KiB
C#

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;
});
});
}
}
}