diff --git a/src/Controls/samples/Controls.Sample.Sandbox/App.xaml.cs b/src/Controls/samples/Controls.Sample.Sandbox/App.xaml.cs index 9512dea98e39..9dc08b9101db 100644 --- a/src/Controls/samples/Controls.Sample.Sandbox/App.xaml.cs +++ b/src/Controls/samples/Controls.Sample.Sandbox/App.xaml.cs @@ -9,16 +9,6 @@ public App() protected override Window CreateWindow(IActivationState? activationState) { - // To test shell scenarios, change this to true - bool useShell = false; - - if (!useShell) - { - return new Window(new NavigationPage(new MainPage())); - } - else - { - return new Window(new SandboxShell()); - } + return new Window(new AppFlyoutPage()); } } diff --git a/src/Controls/samples/Controls.Sample.Sandbox/AppFlyoutPage.xaml b/src/Controls/samples/Controls.Sample.Sandbox/AppFlyoutPage.xaml new file mode 100644 index 000000000000..d43d0013bfc7 --- /dev/null +++ b/src/Controls/samples/Controls.Sample.Sandbox/AppFlyoutPage.xaml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + diff --git a/src/Controls/samples/Controls.Sample.Sandbox/AppFlyoutPage.xaml.cs b/src/Controls/samples/Controls.Sample.Sandbox/AppFlyoutPage.xaml.cs new file mode 100644 index 000000000000..a0fac3aae8ee --- /dev/null +++ b/src/Controls/samples/Controls.Sample.Sandbox/AppFlyoutPage.xaml.cs @@ -0,0 +1,42 @@ +using Maui.Controls.Sample.Services; + +namespace Maui.Controls.Sample; + +public partial class AppFlyoutPage : FlyoutPage +{ + public class MenuItem + { + public string Title { get; set; } = string.Empty; + public Type PageType { get; set; } = typeof(Page); + } + + public List MenuItems { get; set; } + + public AppFlyoutPage() + { + InitializeComponent(); + + MenuItems = new List + { + new MenuItem { Title = "page 1", PageType = typeof(Page1) }, + new MenuItem { Title = "page 2", PageType = typeof(Page2) } + }; + + BindingContext = this; + + // Set default detail page + Detail = new NavigationPage(new Page1()); + } + + private void OnMenuItemSelected(object? sender, SelectionChangedEventArgs e) + { + if (e.CurrentSelection.FirstOrDefault() is MenuItem selectedItem) + { + var navigationService = new NavigationService(); + navigationService.Navigate(selectedItem.PageType); + + // Close the flyout after selection + IsPresented = false; + } + } +} diff --git a/src/Controls/samples/Controls.Sample.Sandbox/Page1.xaml b/src/Controls/samples/Controls.Sample.Sandbox/Page1.xaml new file mode 100644 index 000000000000..5a186b6b4ad2 --- /dev/null +++ b/src/Controls/samples/Controls.Sample.Sandbox/Page1.xaml @@ -0,0 +1,19 @@ + + + +