■ NavigationView 엘리먼트에서 계층 메뉴를 사용하는 방법을 보여준다.
▶ SamplePage1.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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
<Page x:Class="TestProject.SamplePage1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ScrollViewer> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid.Resources> <x:Double x:Key="TileHeightKey">150</x:Double> </Grid.Resources> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid Grid.Row="1" Grid.Column="1" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="DarkGray" /> <Grid Grid.Row="1" Grid.Column="2" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="LightGray" /> <Grid Grid.Row="2" Grid.Column="1" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="LightGray" /> <Grid Grid.Row="2" Grid.Column="2" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="DarkGray" /> <Grid Name="sourceGrid" Grid.Row="1" Grid.Column="0" Grid.RowSpan="2" Margin="5" MinWidth="250" MinHeight="{StaticResource TileHeightKey}" Background="{ThemeResource SystemAccentColor}" /> <Grid Grid.Row="3" Grid.ColumnSpan="3" Margin="5 10"> <TextBlock TextWrapping="WrapWholeWords" Style="{ThemeResource BodyTextBlockStyle}"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </TextBlock> </Grid> </Grid> </ScrollViewer> </Page> |
▶ SamplePage1.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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
using Windows.Foundation.Metadata; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media.Animation; using Windows.UI.Xaml.Navigation; namespace TestProject { /// <summary> /// 샘플 페이지 1 /// </summary> public sealed partial class SamplePage1 : Page { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - SamplePage1() /// <summary> /// 생성자 /// </summary> public SamplePage1() { InitializeComponent(); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public #region 연결 애니메이션 준비하기 - PrepareConnectedAnimation(configuration) /// <summary> /// 연결 애니메이션 준비하기 /// </summary> /// <param name="configuration">연결 애니메이션 구성</param> public void PrepareConnectedAnimation(ConnectedAnimationConfiguration configuration) { ConnectedAnimation animation = ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("ForwardConnectedAnimation", this.sourceGrid); if(configuration != null && ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 7)) { animation.Configuration = configuration; } } #endregion ////////////////////////////////////////////////////////////////////////////////////////// Protected #region 탐색되는 경우 처리하기 - OnNavigatedTo(e) /// <summary> /// 탐색되는 경우 처리하기 /// </summary> /// <param name="e">이벤트 인자</param> protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); ConnectedAnimation animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("BackwardAnimation"); if(animation != null) { animation.TryStart(this.sourceGrid); } } #endregion } } |
▶ SamplePage2.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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
<Page x:Class="TestProject.SamplePage2" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ScrollViewer> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid.Resources> <x:Double x:Key="TileHeightKey">150</x:Double> </Grid.Resources> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid Name="targetGrid" Grid.Row="1" Grid.Column="0" VerticalAlignment="Top" Margin="10" Width="150" MinHeight="{StaticResource TileHeightKey}" Height="200" Background="{ThemeResource SystemAccentColor}" /> <StackPanel Name="contentStackPanel" Grid.Row="1" Grid.Column="1" Margin="10" MinHeight="200"> <TextBlock Style="{ThemeResource TitleTextBlockStyle}" Margin="0 0 0 10" TextWrapping="WrapWholeWords" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit" /> <TextBlock TextWrapping="WrapWholeWords"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </TextBlock> </StackPanel> </Grid> </ScrollViewer> </Page> |
▶ SamplePage2.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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
using Windows.Foundation.Metadata; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media.Animation; using Windows.UI.Xaml.Navigation; namespace TestProject { /// <summary> /// 샘플 페이지 2 /// </summary> public sealed partial class SamplePage2 : Page { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - SamplePage2() /// <summary> /// 생성자 /// </summary> public SamplePage2() { InitializeComponent(); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public #region 연결 애니메이션 준비하기 - PrepareConnectedAnimation(configuration) /// <summary> /// 연결 애니메이션 준비하기 /// </summary> /// <param name="configuration">연결 애니메이션 구성</param> public void PrepareConnectedAnimation(ConnectedAnimationConfiguration configuration) { ConnectedAnimation animation = ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("BackwardAnimation", this.targetGrid); if(configuration != null && ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 7)) { animation.Configuration = configuration; } } #endregion ////////////////////////////////////////////////////////////////////////////////////////// Protected #region 탐색 되는 경우 처리하기 - OnNavigatedTo(e) /// <summary> /// 탐색 되는 경우 처리하기 /// </summary> /// <param name="e">이벤트 인자</param> protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); ConnectedAnimation animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("ForwardAnimation"); if(animation != null) { SetContentStackPanelTransitionCollection(); animation.TryStart(this.targetGrid); } } #endregion ////////////////////////////////////////////////////////////////////////////////////////// Private #region 컨텐트 스택 패널 전이 컬렉션 설정하기 - SetContentStackPanelTransitionCollection() /// <summary> /// 컨텐트 스택 패널 전이 컬렉션 설정하기 /// </summary> private void SetContentStackPanelTransitionCollection() { this.contentStackPanel.Transitions = new TransitionCollection { new EntranceThemeTransition() }; } #endregion } } |
▶ SamplePage3.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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
<Page x:Class="TestProject.SamplePage3" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ScrollViewer> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid.Resources> <x:Double x:Key="TileHeightKey">150</x:Double> </Grid.Resources> <Grid.ColumnDefinitions> <ColumnDefinition Width="2*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid Grid.Row="1" Grid.Column="0" Grid.RowSpan="2" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="LightGray" /> <Grid Grid.Row="1" Grid.Column="1" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="DarkGray" /> <Grid Grid.Row="2" Grid.Column="1" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="Gray" /> <Grid Grid.Row="1" Grid.Column="2" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="LightGray" /> <Grid Grid.Row="2" Grid.Column="2" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="DarkGray" /> <Grid Grid.Row="3" Grid.ColumnSpan="3" Margin="5"> <TextBlock TextWrapping="WrapWholeWords"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </TextBlock> </Grid> </Grid> </ScrollViewer> </Page> |
▶ SamplePage3.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 |
using Windows.UI.Xaml.Controls; namespace TestProject { /// <summary> /// 샘플 페이지 3 /// </summary> public sealed partial class SamplePage3 : Page { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - SamplePage3() /// <summary> /// 생성자 /// </summary> public SamplePage3() { InitializeComponent(); } #endregion } } |
▶ SamplePage4.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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
<Page x:Class="TestProject.SamplePage4" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ScrollViewer> <StackPanel> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid.Resources> <x:Double x:Key="TileHeightKey">150</x:Double> </Grid.Resources> <Grid.ColumnDefinitions> <ColumnDefinition Width="2*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid Grid.Row="1" Grid.Column="0" Grid.RowSpan="2" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="DarkSalmon" /> <Grid Grid.Row="1" Grid.Column="1" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="DarkRed" /> <Grid Grid.Row="1" Grid.Column="2" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="LightCoral" /> </Grid> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid.Resources> <x:Double x:Key="TileHeightKey">150</x:Double> </Grid.Resources> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="2*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid Grid.Row="1" Grid.Column="1" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="DarkRed" /> <Grid Grid.Row="1" Grid.Column="0" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="LightCoral" /> <Grid Grid.Row="1" Grid.Column="2" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="IndianRed" /> <Grid Grid.Row="2" Grid.ColumnSpan="3" Margin="5"> <TextBlock TextWrapping="WrapWholeWords"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </TextBlock> </Grid> </Grid> </StackPanel> </ScrollViewer> </Page> |
▶ SamplePage4.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 |
using Windows.UI.Xaml.Controls; namespace TestProject { /// <summary> /// 샘플 페이지 4 /// </summary> public sealed partial class SamplePage4 : Page { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - SamplePage4() /// <summary> /// 생성자 /// </summary> public SamplePage4() { InitializeComponent(); } #endregion } } |
▶ SamplePage5.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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
<Page x:Class="TestProject.SamplePage5" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ScrollViewer> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid.Resources> <x:Double x:Key="TileHeightKey">150</x:Double> </Grid.Resources> <Grid.ColumnDefinitions> <ColumnDefinition Width="1*" /> <ColumnDefinition Width="1*" /> <ColumnDefinition Width="4*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid Grid.Row="0" Grid.Column="0" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="Khaki" /> <Grid Grid.Row="0" Grid.Column="1" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="DarkKhaki" /> <Ellipse Grid.Row="0" Grid.Column="2" Width="150" Height="150" Fill="DarkSeaGreen" /> <Ellipse Grid.Row="1" Grid.ColumnSpan="2" Width="75" Height="75" Fill="MediumSeaGreen" /> <Grid Grid.Row="1" Grid.Column="2" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="DarkOliveGreen" /> <Grid Grid.Row="3" Grid.ColumnSpan="3" Margin="5"> <TextBlock TextWrapping="WrapWholeWords"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </TextBlock> </Grid> </Grid> </ScrollViewer> </Page> |
▶ SamplePage5.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 |
using Windows.UI.Xaml.Controls; namespace TestProject { /// <summary> /// 샘플 페이지 5 /// </summary> public sealed partial class SamplePage5 : Page { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - SamplePage5() /// <summary> /// 생성자 /// </summary> public SamplePage5() { InitializeComponent(); } #endregion } } |
▶ SamplePage6.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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
<Page x:Class="TestProject.SamplePage6" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ScrollViewer> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid.Resources> <x:Double x:Key="TileHeightKey">150</x:Double> </Grid.Resources> <Grid.ColumnDefinitions> <ColumnDefinition Width="1*" /> <ColumnDefinition Width="1*" /> <ColumnDefinition Width="4*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Ellipse Grid.Row="0" Grid.Column="0" Width="20" Height="20" Fill="MediumTurquoise" /> <Ellipse Grid.Row="0" Grid.Column="1" Width="50" Height="50" Fill="SteelBlue" /> <Grid Grid.Row="0" Grid.Column="2" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="SkyBlue" /> <Ellipse Grid.Row="1" Grid.Column="0" Width="50" Height="50" Fill="PowderBlue" /> <Ellipse Grid.Row="1" Grid.Column="1" Width="20" Height="20" Fill="MediumTurquoise" /> <Grid Grid.Row="1" Grid.Column="2" Margin="5" MinHeight="{StaticResource TileHeightKey}" Background="SteelBlue" /> <Grid Grid.Row="3" Grid.ColumnSpan="3" Margin="5"> <TextBlock TextWrapping="WrapWholeWords"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </TextBlock> </Grid> </Grid> </ScrollViewer> </Page> |
▶ SamplePage6.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 |
using Windows.UI.Xaml.Controls; namespace TestProject { /// <summary> /// 샘플 페이지 6 /// </summary> public sealed partial class SamplePage6 : Page { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - SamplePage6() /// <summary> /// 생성자 /// </summary> public SamplePage6() { InitializeComponent(); } #endregion } } |
▶ SampleSettingPage.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<Page x:Class="TestProject.SampleSettingPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <TextBlock Style="{StaticResource TitleTextBlockStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" Text="샘플 설정 페이지" /> </Grid> </Page> |
▶ SampleSettingPage.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 |
using Windows.UI.Xaml.Controls; namespace TestProject { /// <summary> /// 샘플 설정 페이지 /// </summary> public sealed partial class SampleSettingPage : Page { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - SampleSettingPage() /// <summary> /// 생성자 /// </summary> public SampleSettingPage() { InitializeComponent(); } #endregion } } |
▶ 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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
<Page x:Class="TestProject.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:muxc="using:Microsoft.UI.Xaml.Controls" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" FontFamily="나눔고딕코딩" FontSize="16"> <Grid> <Grid Margin="10"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="10" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <muxc:NavigationView Name="navigationView" Grid.Column="0" IsTabStop="False" PaneDisplayMode="Left" SelectionChanged="navigationView_SelectionChanged"> <muxc:NavigationView.MenuItems> <muxc:NavigationViewItem Content="홈" Icon="Home" ToolTipService.ToolTip="홈" Tag="SamplePage1" /> <muxc:NavigationViewItem Content="계정" Icon="Contact" ToolTipService.ToolTip="계정" Tag="SamplePage2"> <muxc:NavigationViewItem.MenuItems> <muxc:NavigationViewItem Content="메일" Icon="Mail" ToolTipService.ToolTip="Mail" Tag="SamplePage3" /> <muxc:NavigationViewItem Content="달력" Icon="Calendar" ToolTipService.ToolTip="달력" Tag="SamplePage4" /> </muxc:NavigationViewItem.MenuItems> </muxc:NavigationViewItem> <muxc:NavigationViewItem Content="문서 옵션" Icon="Page2" ToolTipService.ToolTip="문서 옵션" SelectsOnInvoked="False"> <muxc:NavigationViewItem.MenuItems> <muxc:NavigationViewItem Content="신규 생성" Icon="NewFolder" ToolTipService.ToolTip="신규 생성" Tag="SamplePage5" /> <muxc:NavigationViewItem Content="파일 업로드" Icon="OpenLocal" ToolTipService.ToolTip="파일 업로드" Tag="SamplePage6" /> </muxc:NavigationViewItem.MenuItems> </muxc:NavigationViewItem> </muxc:NavigationView.MenuItems> <Frame x:Name="frame" /> </muxc:NavigationView> <StackPanel Grid.Column="2" Spacing="10"> <TextBlock Text="창 위치 :" /> <RadioButton GroupName="hierachicalGroup" Content="왼쪽 모드" Checked="leftPanePositionRadioButton_Checked" IsChecked="True" /> <RadioButton GroupName="hierachicalGroup" Content="위쪽 모드" Checked="topPanePositionRadioButton_Checked"/> <RadioButton GroupName="hierachicalGroup" Content="왼쪽 컴팩트 모드" Checked="leftCompactPanePositionRadioButton_Checked" /> </StackPanel> </Grid> </Grid> </Page> |
▶ MainPage.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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
using System; using Windows.Foundation; using Windows.Graphics.Display; using Windows.UI.ViewManagement; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; namespace TestProject { /// <summary> /// 메인 페이지 /// </summary> public sealed partial class MainPage : Page { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainPage() /// <summary> /// 생성자 /// </summary> public MainPage() { InitializeComponent(); #region 윈도우 크기를 설정한다. double width = 800d; double height = 600d; double dpi = (double)DisplayInformation.GetForCurrentView().LogicalDpi; ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize; Size windowSize = new Size(width * 96d / dpi, height * 96d / dpi); ApplicationView.PreferredLaunchViewSize = windowSize; Window.Current.Activate(); ApplicationView.GetForCurrentView().TryResizeView(windowSize); #endregion #region 윈도우 제목을 설정한다. ApplicationView.GetForCurrentView().Title = "NavigationView 엘리먼트 : 계층 메뉴 사용하기"; #endregion } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 네비게이션 뷰 선택 변경시 처리하기 - navigationView_SelectionChanged(sender, e) /// <summary> /// 네비게이션 뷰 선택 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void navigationView_SelectionChanged(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewSelectionChangedEventArgs e) { if(e.IsSettingsSelected) { this.frame.Navigate(typeof(SampleSettingPage)); } else { Microsoft.UI.Xaml.Controls.NavigationViewItem item = e.SelectedItem as Microsoft.UI.Xaml.Controls.NavigationViewItem; string itemTag = item.Tag.ToString(); sender.Header = "샘플 페이지 " + itemTag.Substring(itemTag.Length - 1); string pageName = "TestProject." + itemTag; Type pageType = Type.GetType(pageName); this.frame.Navigate(pageType); } } #endregion #region 왼쪽 창 위치 라디오 버튼 체크시 처리하기 - leftPanePositionRadioButton_Checked(sender, e) /// <summary> /// 왼쪽 창 위치 라디오 버튼 체크시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void leftPanePositionRadioButton_Checked(object sender, RoutedEventArgs e) { this.navigationView.PaneDisplayMode = Microsoft.UI.Xaml.Controls.NavigationViewPaneDisplayMode.Left; this.navigationView.IsPaneOpen = true; } #endregion #region 위쪽 창 위치 라디오 버튼 체크시 처리하기 - topPanePositionRadioButton_Checked(sender, e) /// <summary> /// 위쪽 창 위치 라디오 버튼 체크시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void topPanePositionRadioButton_Checked(object sender, RoutedEventArgs e) { this.navigationView.PaneDisplayMode = Microsoft.UI.Xaml.Controls.NavigationViewPaneDisplayMode.Top; this.navigationView.IsPaneOpen = false; } #endregion #region 왼쪽 컴팩트 창 위치 라디오 버튼 체크시 처리하기 - leftCompactPanePositionRadioButton_Checked(sender, e) /// <summary> /// 왼쪽 컴팩트 창 위치 라디오 버튼 체크시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void leftCompactPanePositionRadioButton_Checked(object sender, RoutedEventArgs e) { this.navigationView.PaneDisplayMode = Microsoft.UI.Xaml.Controls.NavigationViewPaneDisplayMode.LeftCompact; this.navigationView.IsPaneOpen = false; } #endregion } } |