Exemplo n.º 1
0
 public MainPageView()
 {
     InitializeComponent();
     flyout.ListView.SelectionChanged += ListView_SelectionChanged;
     FlyoutLayoutBehavior              = FlyoutLayoutBehavior.SplitOnLandscape;
     ViewModel             = App.ServiceProvider.GetRequiredService <MainPageViewModel>();
     this.BindingContext   = ViewModel;
     flyout.BindingContext = ViewModel;
     FlowSettingsChanged(Descriptors.GetFlowSettings <EditFormSettingsDescriptor>("students"));
 }
Exemplo n.º 2
0
        private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.CurrentSelection.Count != 1)
            {
                return;
            }

            if (!(e.CurrentSelection.First() is NavigationMenuItemDescriptor item))
            {
                return;
            }
            if (item.Active)
            {
                return;
            }


            DisposeCurrentPageBindingContext(Detail);

            FlowSettingsChanged(Descriptors.GetFlowSettings <EditFormSettingsDescriptor>(item.InitialModule));
            //Page page = null;

            //if (item.InitialModule != "students" && item.InitialModule != "courses")
            //    return;
            //if (item.TargetType == typeof(EditFormViewCS))
            //{
            //    //page = new EditFormViewCS(CreateEditFormViewModel(Descriptors.ScreenSettings));
            //}
            //else if(item.TargetType == typeof(EditFormView))
            //{
            //    //page = new EditFormView(CreateEditFormViewModel(Descriptors.ScreenSettings));
            //}
            //else
            //{
            //    page = (Page)Activator.CreateInstance(item.TargetType);
            //}

            //page = new EditFormViewCS(CreateEditFormViewModel(Descriptors.ScreenSettings));

            //page.Title = item.Text;

            //Xamarin.Essentials.MainThread.BeginInvokeOnMainThread
            //(
            //    () => Detail = GetNavigationPage(page)
            //);

            //if (IsPortrait)
            //    IsPresented = false;

            //flyout.ListView.SelectedItem = null;

            void DisposeCurrentPageBindingContext(Page detail)
            {
                if (detail is not NavigationPage navigationPage)
                {
                    return;
                }

                if (navigationPage?.RootPage.BindingContext is not IDisposable disposable)
                {
                    return;
                }

                disposable.Dispose();
            }
        }