■ BarManager 클래스에서 하위 메뉴 및 내장 에디터를 포함하는 BAR를 생성하는 방법을 보여준다.
▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
<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> |
▶ MainWindow.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
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 } } |