첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
다운로드

▶ 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"
    xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
    Width="800"
    Height="600"
    Title="BAR 커스텀 액션 정의하기"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Window.Resources>
        <DataTemplate x:Key="DataTemplateKey1">
            <dxb:BarManagerActionContainer>
                <dxb:CreateStandardLayoutAction />
                <dxb:InsertMainMenuIfNotExistAction>
                    <dxb:InsertMainMenuIfNotExistAction.Bar>
                        <dxb:Bar x:Name="MainMenu"
                            UseWholeRow="True"
                            Caption="Main menu">
                            <dxb:Bar.DockInfo>
                                <dxb:BarDockInfo ContainerType="Top" />
                            </dxb:Bar.DockInfo>
                        </dxb:Bar>
                    </dxb:InsertMainMenuIfNotExistAction.Bar>
                </dxb:InsertMainMenuIfNotExistAction>
                <dxb:BarSubItem x:Name="fileBarSubItem"
                    dxb:BarItemLinkActionBase.TargetType="MainMenu"
                    dxb:BarItemLinkActionBase.ItemLinkIndex="0"
                    Content="File" />
                <dxb:BarButtonItem x:Name="newBarButtonItem"
                    dxb:BarItemLinkActionBase.Target="fileBarSubItem"
                    dxb:BarItemLinkActionBase.ItemLinkIndex="0"
                    Content="New" />
                <dxb:BarButtonItem x:Name="_pOpenBarButtonItem"
                    dxb:BarItemLinkActionBase.Target="fileBarSubItem"
                    dxb:BarItemLinkActionBase.ItemLinkIndex="1"
                    Content="Open" />
                <dxb:BarButtonItem x:Name="saveBarButtonItem"
                    dxb:BarItemLinkActionBase.Target="fileBarSubItem"
                    dxb:BarItemLinkActionBase.ItemLinkIndex="2"
                    Content="Save" />
                <dxb:BarButtonItem x:Name="exitBarButtonItem"
                    dxb:BarItemLinkActionBase.Target="fileBarSubItem"
                    dxb:BarItemLinkActionBase.ItemLinkIndex="3"
                    Content="Exit" />
                <dxb:BarSubItem x:Name="helpBarSubItem"
                    dxb:BarItemLinkActionBase.TargetType="MainMenu"
                    Content="Help" />
                <dxb:BarButtonItem x:Name="aboutBarButtonItem"
                    dxb:BarItemLinkActionBase.Target="helpBarSubItem"
                    Content="About" />
            </dxb:BarManagerActionContainer>
        </DataTemplate>
        <DataTemplate x:Key="DataTemplateKey2">
            <dxb:BarManagerActionContainer>
                <dxb:RemoveBarItemAndLinkAction ItemName="helpBarSubItem"    />
                <dxb:RemoveBarItemAndLinkAction ItemName="exitBarButtonItem" />
            </dxb:BarManagerActionContainer>
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <dxb:BarManager CreateStandardLayout="True">
            <dxb:BarManager.Controllers>
                <dxb:TemplatedBarManagerController
                    ExecuteBefore="True"
                    Template="{StaticResource DataTemplateKey1}" />
                <dxb:TemplatedBarManagerController
                    ExecuteBefore="False"
                    Template="{StaticResource DataTemplateKey2}" />
            </dxb:BarManager.Controllers>
            <dxb:BarManager.Items>
                <dxb:BarCheckItem x:Name="boldBarCheckItem"
                    Content="Bold" />
                <dxb:BarCheckItem x:Name="italicBarCheckItem"
                    Content="Italic" />
                <dxb:BarCheckItem x:Name="underlineBarCheckItem"
                    Content="Underline" />
            </dxb:BarManager.Items>
            <dxb:BarManager.Bars>
                <dxb:Bar x:Name="formatBar"
                    Caption="Format Bar">
                    <dxb:Bar.DockInfo>
                        <dxb:BarDockInfo
                            ContainerType="Top"
                            Row="1" />
                    </dxb:Bar.DockInfo>
                    <dxb:Bar.ItemLinks>
                        <dxb:BarCheckItemLink BarItemName="boldBarCheckItem"      />
                        <dxb:BarCheckItemLink BarItemName="italicBarCheckItem"    />
                        <dxb:BarCheckItemLink BarItemName="underlineBarCheckItem" />
                    </dxb:Bar.ItemLinks>
                </dxb:Bar>
            </dxb:BarManager.Bars>
            <RichTextBox />
        </dxb:BarManager>
    </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();
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요