첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
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"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    Width="800"
    Height="600"
    Title="BarManager 클래스 : 하위 메뉴 및 내장 에디터를 포함하는 BAR 생성하기"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Grid>
        <dxb:BarManager>
            <dxb:BarManager.Items>
                <dxb:BarSubItem x:Name="editBarSubItem"
                    Content="Edit">
                    <dxb:BarButtonItemLink BarItemName="copyBarButtonItem" />
                    <dxb:BarCheckItemLink  BarItemName="boldBarCheckItem"  />
                </dxb:BarSubItem>
                <dxb:BarButtonItem x:Name="copyBarButtonItem"
                    Content="Copy"
                    Glyph="pack://application:,,,/DevExpress.Images.v13.2;component/Images/Edit/Copy_16x16.png"
                    ItemClick="copyBarButtonItem_ItemClick" />
                <dxb:BarCheckItem x:Name="boldBarCheckItem"
                    Content="Bold"
                    Glyph="pack://application:,,,/DevExpress.Images.v13.2;component/Images/Format/Bold_16x16.png"
                    CheckedChanged="boldBarCheckItem_CheckedChanged" />
                <dxb:BarEditItem x:Name="textBarEditItem"
                    EditWidth="100"
                    EditValue="text">
                    <dxb:BarEditItem.EditSettings>
                        <dxe:TextEditSettings x:Name="textEditSettings" />
                    </dxb:BarEditItem.EditSettings>
                </dxb:BarEditItem>
            </dxb:BarManager.Items>
            <dxb:BarManager.Bars>
                <dxb:Bar x:Name="mainMenuBar"
                    Caption="Main Menu"
                    IsMainMenu="True">
                    <dxb:Bar.DockInfo>
                        <dxb:BarDockInfo ContainerType="Top"/>
                    </dxb:Bar.DockInfo>
                    <dxb:BarEditItemLink BarItemName="textBarEditItem" />
                </dxb:Bar>
                <dxb:Bar Caption="Bar 1">
                    <dxb:Bar.DockInfo>
                        <dxb:BarDockInfo ContainerType="Top" />
                    </dxb:Bar.DockInfo>
                    <dxb:BarSubItemLink BarItemName="editBarSubItem" />
                </dxb:Bar>
                <dxb:Bar x:Name="statusBar"
                    Caption="Status Bar"
                    IsStatusBar="True">
                    <dxb:Bar.DockInfo>
                        <dxb:BarDockInfo ContainerType="Bottom" />
                    </dxb:Bar.DockInfo>
                </dxb:Bar>
            </dxb:BarManager.Bars>
            <DockPanel>
                <RichTextBox>
                    <FlowDocument>
                        <Paragraph>
                            <Run Text="RichTextBox" />
                        </Paragraph>
                    </FlowDocument>
                </RichTextBox>
            </DockPanel>
        </dxb:BarManager>
    </Grid>
</Window>

 

728x90

 

▶ MainWindow.xaml.cs

using System.Windows;

using DevExpress.Xpf.Bars;

namespace TestProject
{
    /// <summary>
    /// 메인 윈도우
    /// </summary>
    public partial class MainWindow : Window
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainWindow()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            this.textBarEditItem.EditValueChanged += textBarEditItem_EditValueChanged;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region Copy 막대 버튼 항목 항목 클릭시 처리하기 - copyBarButtonItem_ItemClick(sender, e)

        /// <summary>
        /// Copy 막대 버튼 항목 항목 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void copyBarButtonItem_ItemClick(object sender, ItemClickEventArgs e)
        {
            MessageBox.Show((e.Item.Content as string) + " 항목이 클릭되었습니다.");
        }

        #endregion
        #region Bold 막대 체크 항목 체크 변경시 처리하기 - boldBarCheckItem_CheckedChanged(sender, e)

        /// <summary>
        /// Bold 막대 체크 항목 체크 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void boldBarCheckItem_CheckedChanged(object sender, ItemClickEventArgs e)
        {
            BarCheckItem barCheckItem = e.Item as BarCheckItem;

            string content = e.Item.Content as string;

            if(barCheckItem.IsChecked.Value)
            {
                MessageBox.Show(content + " 항목이 체크되었습니다.");
            }
            else
            {
                MessageBox.Show(content + " 항목이 체크 해제되었습니다.");
            }
        }

        #endregion
        #region 텍스트 막대 편집 항목 편집 값 변경시 처리하기 - textBarEditItem_EditValueChanged(sender, e)

        /// <summary>
        /// 텍스트 막대 편집 항목 편집 값 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void textBarEditItem_EditValueChanged(object sender, RoutedEventArgs e)
        {
            BarEditItem barEditItem = sender as BarEditItem;

            MessageBox.Show(barEditItem.EditValue.ToString());
        }

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

댓글을 달아 주세요