728x90
반응형
728x170
▶ MainWindow.cs
using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using System.Windows.Media;
namespace TestProject
{
/// <summary>
/// 메인 윈도우
/// </summary>
public class MainWindow : Window
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainWindow()
/// <summary>
/// 생성자
/// </summary>
public MainWindow()
{
Width = 800;
Height = 600;
Title = "XAML 리소스 로드하기";
FontFamily = new FontFamily("나눔고딕코딩");
FontSize = 16;
Uri uri = new Uri("pack://application:,,,/Resource.xml");
Stream stream = Application.GetResourceStream(uri).Stream;
FrameworkElement frameworkElement = XamlReader.Load(stream) as FrameworkElement;
Content = frameworkElement;
Button button = frameworkElement.FindName("button") as Button;
if(button != null)
{
button.Click += button_Click;
}
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Static
//////////////////////////////////////////////////////////////////////////////// Public
#region 프로그램 시작하기 - Main()
/// <summary>
/// 프로그램 시작하기
/// </summary>
[STAThread]
public static void Main()
{
Application application = new Application();
application.Run(new MainWindow());
}
#endregion
////////////////////////////////////////////////////////////////////////////////////////// Instance
//////////////////////////////////////////////////////////////////////////////// Private
#region 버튼 클릭시 처리하기 - button_Click(sender, e)
/// <summary>
/// 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("The button labeled '" + (e.Source as Button).Content + "' has been clicked");
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] 커스텀 엘리먼트 바인딩 사용하기 (0) | 2018.03.24 |
---|---|
[C#/WPF] XAML 문서 리더 만들기 (0) | 2018.03.24 |
[C#/WPF] Content 속성 어트리뷰트 출력하기 (0) | 2018.03.24 |
[C#/WPF] XAML 동적 생성하기 (0) | 2018.03.24 |
[C#/WPF] XAML 윈도우 로드하기 (0) | 2018.03.24 |
[C#/WPF] XAML 리소스 로드하기 (0) | 2018.03.24 |
[C#/WPF] 내장 XAML 로드하기 (0) | 2018.03.24 |
[C#/WPF] 메모장 흉내내기 (0) | 2018.03.24 |
[C#/WPF] 의존 속성 탐색하기 (0) | 2018.03.24 |
[C#/WPF] 시스템 매개 변수 조회하기 (0) | 2018.03.24 |
[C#/WPF] 클래스 계층도 표시하기 (0) | 2018.03.24 |
댓글을 달아 주세요