Programing (프로그래밍)/WPF & C# (C Sharp)
WPF & C# - 시작 변수_메인 메소드_Args_StartupEventArgs
insurang
2019. 7. 1. 23:28
728x90
반응형
App.xaml 의 Startup 수정 후 아래와같이 변수를 받으면 된다.
보통 확장자 연결 후 해당 파일 더블클릭하면 넘어가는 변수이다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
public partial class App : Application
{
private void Startup(object sender, StartupEventArgs e)
{
MainWindow wnd = new MainWindow();
if (e.Args.Length >= 1)
MessageBox.Show(e.Args[0]);
wnd.Show();
}
}
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
|
cs |
일반적으로 도스모스에서는 실행파일 뒤에 변수값을 넣어서 사용한다.
string[] args = Environment.GetCommandLineArgs();
Application.Startup Event (System.Windows)
Occurs when the method of the object is called.
docs.microsoft.com
기본 애플리케이션 창 가져오기 및 설정
StartupEventArgs
https://docs.microsoft.com/ko-kr/dotnet/api/system.windows.startupeventargs?view=netframework-4.8
StartupEventArgs Class (System.Windows)
이벤트에 대한 인수가 포함되어 있습니다.Contains the arguments for the event.
docs.microsoft.com
728x90
반응형