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

47 lines
1.2 KiB
C#
Raw Permalink Normal View History

2021-08-03 16:43:16 +00:00
using MobileApp1.Models;
using System.Threading.Tasks;
using Xamarin.Forms;
2021-08-02 21:49:48 +00:00
using Xamarin.Forms.Xaml;
namespace MobileApp1.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class FlyoutMenuPage : ContentPage
{
public FlyoutMenuPage()
{
InitializeComponent();
2021-08-03 16:43:16 +00:00
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;
});
});
2021-08-02 21:49:48 +00:00
}
2021-08-03 16:43:16 +00:00
2021-08-02 21:49:48 +00:00
}
}