■ XAML 윈도우 로드하기

----------------------------------------------------------------------------------------------------


TestProject.zip


Program.cs

 

 

using System;

using System.IO;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Markup;

 

namespace TestProject

{

    /// <summary>

    /// 프로그램

    /// </summary>

    public class Program

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method

        ////////////////////////////////////////////////////////////////////////////////////////// Static

        //////////////////////////////////////////////////////////////////////////////// Public

 

        #region 프로그램 시작하기 - Main()

 

        /// <summary>

        /// 프로그램 시작하기

        /// </summary>

        [STAThread]

        public static void Main()

        {

            Application application = new Application();

 

            Uri uri = new Uri("pack://application:,,,/MainWindow.xml");

 

            Stream stream = Application.GetResourceStream(uri).Stream;

 

            Window window = XamlReader.Load(stream) as Window;

 

            window.AddHandler(Button.ClickEvent, new RoutedEventHandler(button_Click));

 

            application.Run(window);

        }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////// Private

 

        #region 버튼 클릭시 처리하기 - button_Click(sender, e)

 

        /// <summary>

        /// 버튼 클릭시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private static void button_Click(object sender, RoutedEventArgs e)

        {

            MessageBox.Show("The button labeled '" + (e.Source as Button).Content + "' has been clicked");

        }

 

        #endregion

    }

}

 

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG