첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
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="컨트롤에 팝업 메뉴 결합하기"
    FontFamily="나눔고딕코딩"
    FontSize="16">
    <Grid>
        <dxb:BarManager x:Name="barManager"
            CreateStandardLayout="True">
            <dxb:BarManager.Items>
                <dxb:BarButtonItem x:Name="copyBarButtonItem"
                    Content="Copy"
                    Glyph="pack://application:,,,/Image/copy16x16.png"
                    ItemClick="copyBarButtonItem_ItemClick" />
                <dxb:BarButtonItem x:Name="pasteBarButtonItem"
                    Content="Paste"
                    Glyph="pack://application:,,,/Image/paste16x16.png"
                    ItemClick="pasteBarButtonItem_ItemClick" />
                <dxb:BarButtonItem x:Name="undoBarButtonItem"
                    Content="Undo"
                    Glyph="pack://application:,,,/Image/undo16x16.png"
                    ItemClick="undoBarButtonItem_ItemClick" />
                <dxb:BarButtonItem x:Name="redoBarButtonItem"
                    Content="Redo"
                    Glyph="pack://application:,,,/Image/redo16x16.png"
                    ItemClick="redoBarButtonItem_ItemClick" />
            </dxb:BarManager.Items>
            <DockPanel>
                <TextBox x:Name="textBox"
                    Width="200"
                    Height="30"
                    FontSize="16"
                    Text="right-click this textbox">
                    <dxb:BarManager.DXContextMenu>
                        <dxb:PopupMenu>
                            <dxb:PopupMenu.ItemLinks>
                                <dxb:BarButtonItemLink BarItemName="copyBarButtonItem"  />
                                <dxb:BarButtonItemLink BarItemName="pasteBarButtonItem" />
                                <dxb:BarButtonItemLink BarItemName="undoBarButtonItem"  />
                                <dxb:BarButtonItemLink BarItemName="redoBarButtonItem"  />
                            </dxb:PopupMenu.ItemLinks>
                        </dxb:PopupMenu>
                    </dxb:BarManager.DXContextMenu>
                </TextBox>
            </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();
        }

        #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)
        {
            this.textBox.Copy();
        }

        #endregion
        #region Paste 바 버튼 항목 항목 클릭시 처리하기 - copyBarButtonItem_ItemClick(sender, e)

        /// <summary>
        /// Paste 바 버튼 항목 항목 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void pasteBarButtonItem_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.textBox.Paste();
        }

        #endregion
        #region Undo 바 버튼 항목 항목 클릭시 처리하기 - copyBarButtonItem_ItemClick(sender, e)

        /// <summary>
        /// Undo 바 버튼 항목 항목 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void undoBarButtonItem_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.textBox.Undo();
        }

        #endregion
        #region Redo 바 버튼 항목 항목 클릭시 처리하기 - copyBarButtonItem_ItemClick(sender, e)

        /// <summary>
        /// Redo 바 버튼 항목 항목 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void redoBarButtonItem_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.textBox.Redo();
        }

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

댓글을 달아 주세요