728x90
728x170
▶ 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="Application 클래스 : Restart 메소드를 사용해 애플리케이션 재시작하기"
FontFamily="나눔고딕코딩"
FontSize="16">
<Grid>
<Button Name="restartButton"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="100"
Height="30"
Content="재시작" />
</Grid>
</Window>
728x90
▶ MainWindow.xaml.cs
using System.Windows;
namespace TestProject
{
/// <summary>
/// 메인 윈도우
/// </summary>
public partial class MainWindow : Window
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainWindow()
/// <summary>
/// 생성자
/// </summary>
public MainWindow()
{
InitializeComponent();
this.restartButton.Click += restartButton_Click;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region 재시작 버튼 클릭시 처리하기 - restartButton_Click(sender, e)
/// <summary>
/// 재시작 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void restartButton_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
System.Windows.Forms.Application.Restart();
}
#endregion
}
}
728x90
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] 누겟 설치 : FontAwesome.WPF (0) | 2021.09.11 |
---|---|
[C#/WPF] GOM 플레이어 모방하기 (0) | 2021.09.05 |
[C#/WPF] LinearGradientBrush 엘리먼트 사용하기 (0) | 2021.08.24 |
[C#/WPF] Vector 구조체 : 각도에서 벡터 구하기 (0) | 2021.08.20 |
[C#/WPF] Window 클래스 : 커스텀 윈도우 사용하기 (0) | 2021.08.20 |
[C#/WPF] Vector 구조체 : 벡터 각도 구하기 (0) | 2021.08.19 |
[C#/WPF] ResourceDictionary 클래스 : MergedDictionaries 속성을 사용해 Application 객체의 리소스 사용하기 (0) | 2021.07.08 |
[C#/WPF] ControlTemplate 엘리먼트 : Thumb/ScrollBar/ListBoxItem 엘리먼트 정의하기 (0) | 2021.06.07 |
[C#/WPF] HwndSource 클래스 : FromHwnd 정적 메소드를 사용해 윈도우 핸들로 윈도우 구하기 (0) | 2021.06.07 |
[C#/WPF] 잠금 화면 설정하기 (기능 개선) (0) | 2021.05.31 |