첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ ToolBarTray 클래스 사용하기

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


TestProject.zip


MainWindow.cs

 

 

using System;

using System.Windows;

using System.Windows.Controls;

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      = "ToolBarTray 클래스 사용하기";

            FontFamily = new FontFamily("나눔고딕코딩");

            FontSize   = 16;

 

            DockPanel dockPanel = new DockPanel();

 

            Content = dockPanel;

 

            ToolBarTray topToolBarTray = new ToolBarTray();

 

            dockPanel.Children.Add(topToolBarTray);

 

            DockPanel.SetDock(topToolBarTray, Dock.Top);

 

            ToolBarTray leftToolBarTray = new ToolBarTray();

 

            leftToolBarTray.Orientation = Orientation.Vertical;

 

            dockPanel.Children.Add(leftToolBarTray);

 

            DockPanel.SetDock(leftToolBarTray, Dock.Left);

 

            TextBox textBox = new TextBox();

 

            dockPanel.Children.Add(textBox);

 

            for(int i = 0; i < 6; i++)

            {

                ToolBar toolBar = new ToolBar();

 

                toolBar.Header = "툴바 " + (i + 1);

 

                if(i < 3)

                {

                    topToolBarTray.ToolBars.Add(toolBar);

                }

                else

                {

                    leftToolBarTray.ToolBars.Add(toolBar);

                }

 

                for(int j = 0; j < 6; j++)

                {

                    Button button = new Button();

 

                    button.FontSize = 16;

 

                    button.Content = (char)('A' + j);

 

                    toolBar.Items.Add(button);

                }

            }

        }

 

        #endregion

 

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

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

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

 

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

 

        /// <summary>

        /// 프로그램 시작하기

        /// </summary>

        [STAThread]

        public static void Main()

        {

            Application application = new Application();

 

            application.Run(new MainWindow());

        }

 

        #endregion

    }

}

 

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

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요