728x90
반응형
728x170
■ Frame 클래스의 Navigate 메소드를 사용해 페이지를 이동하는 방법을 보여준다.
▶ MainWindow.xaml
<Window x:Class="TestProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="800"
Height="600"
Title="Frame 클래스 : Navigate 메소드를 사용해 페이지 이동하기"
FontFamily="나눔고딕코딩"
FontSize="16">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Button Name="button1"
Margin="10"
Padding="5">
페이지 1
</Button>
<Button Name="button2"
Margin="10"
Padding="5">
페이지 2
</Button>
<Button Name="button3"
Margin="10"
Padding="5">
페이지 3
</Button>
</StackPanel>
<Frame Name="frame" Grid.Row="1"
NavigationUIVisibility="Visible" />
</Grid>
</Window>
▶ MainWindow.xaml.cs
using System;
using System.Windows;
namespace TestProject
{
/// <summary>
/// 메인 윈도우
/// </summary>
public partial class MainWindow : Window
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainWindow()
/// <summary>
/// 생성자
/// </summary>
public MainWindow()
{
InitializeComponent();
this.button1.Click += button1_Click;
this.button2.Click += button2_Click;
this.button3.Click += button3_Click;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region 페이지 1 버튼 클릭시 처리하기 - button1_Click(sender, e)
/// <summary>
/// 페이지 1 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void button1_Click(object sender, RoutedEventArgs e)
{
this.frame.Navigate(new Uri("Page1.xaml", UriKind.RelativeOrAbsolute));
}
#endregion
#region 페이지 2 버튼 클릭시 처리하기 - button2_Click(sender, e)
/// <summary>
/// 페이지 2 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void button2_Click(object sender, RoutedEventArgs e)
{
this.frame.Navigate(new Uri("Page2.xaml", UriKind.RelativeOrAbsolute));
}
#endregion
#region 페이지 3 버튼 클릭시 처리하기 - button3_Click(sender, e)
/// <summary>
/// 페이지 3 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void button3_Click(object sender, RoutedEventArgs e)
{
this.frame.Navigate(new Uri("Page3.xaml", UriKind.RelativeOrAbsolute));
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] Mouse 클래스 : OverrideCursor 정적 속성을 사용해 커서 설정하기 (0) | 2020.08.09 |
---|---|
[C#/WPF] Clipboard 클래스 : GetText 정적 메소드를 사용해 HTML 구하기 (0) | 2020.08.08 |
[C#/WPF] UIElement 클래스 : DragEnter/GiveFeedback/DragOver/Drop/DragLeave 이벤트를 사용해 드래그하기 (0) | 2020.08.08 |
[C#/WPF] Thumb 엘리먼트 : DragStarted/DragDelta/DragCompleted 이벤트를 사용해 드래그 하기 (0) | 2020.08.08 |
[C#/WPF] Calendar 클래스 사용하기 (0) | 2020.08.08 |
[C#/WPF] Button 엘리먼트 : Background 속성 사용하기 (0) | 2020.08.08 |
[C#/WPF] BulletDecorator 엘리먼트 사용하기 (0) | 2020.08.08 |
[C#/WPF] DrawingVisual 클래스 사용하기 (0) | 2020.08.07 |
[C#/WPF] UIElement 엘리먼트 : Clip 속성 사용하기 (0) | 2020.08.07 |
[C#/WPF] DrawingContext 클래스 : PushClip 메소드를 사용해 클리핑 영역 설정하기 (0) | 2020.08.06 |
댓글을 달아 주세요