■ MenuBarItem 엘리먼트를 사용하는 방법을 보여준다. (UWP)
▶ MainPage.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?xml version="1.0" encoding="utf-8" ?> <ContentPage x:Class="TestProject.MainPage" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"> <ContentPage.MenuBarItems> <MenuBarItem Text="File"> <MenuFlyoutItem Text="Exit" /> </MenuBarItem> <MenuBarItem Text="Locations"> <MenuFlyoutSubItem Text="Change Location"> <MenuFlyoutItem Text="Redmond, USA" /> <MenuFlyoutItem Text="London, UK" /> <MenuFlyoutItem Text="Berlin, DE" /> </MenuFlyoutSubItem> <MenuFlyoutItem Text="Add Location" /> </MenuBarItem> <MenuBarItem Text="View"> <MenuFlyoutItem Text="Refresh" /> <MenuFlyoutItem Text="Change Theme" /> </MenuBarItem> </ContentPage.MenuBarItems> </ContentPage> |
▶ App.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
namespace TestProject; /// <summary> /// 앱 /// </summary> public partial class App : Application { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - App() /// <summary> /// 생성자 /// </summary> public App() { InitializeComponent(); NavigationPage navigationPage = new NavigationPage(new MainPage()); MainPage = navigationPage; } #endregion } |
※ 데스크톱 앱 실행시만 표시된다.
※ 데스크톱 앱은 NavigationPage 또는 Shell 앱에서 호스팅되는 ContentPage에 추가될 때 메뉴 항목을 포함하는 메뉴 모음을 표시한다.