■ BarManager 클래스에서 버튼 항목과 하위 메뉴를 갖는 2개의 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 |
<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="BarManager 클래스 : 버튼 항목과 하위 메뉴를 갖는 2개의 BAR 생성하기" FontFamily="나눔고딕코딩" FontSize="16"> <Grid> <dxb:BarManager x:Name="barManager" CreateStandardLayout="True"> <dxb:BarManager.Items> <dxb:BarCheckItem x:Name="boldBarCheckItem" Glyph="pack://application:,,,/Image/bold16x16.png" Content="Bold" CheckedChanged="boldBarCheckItem_CheckChanged" /> <dxb:BarButtonItem x:Name="exitBarButtonItem" Content="Exit" ItemClick="exitBarButtonItem_ItemClick"/> <dxb:BarSubItem x:Name="fileBarSubItem" Content="File"> <dxb:BarSubItem.ItemLinks> <dxb:BarButtonItemLink BarItemName="exitBarButtonItem"/> </dxb:BarSubItem.ItemLinks> </dxb:BarSubItem> <dxb:BarSubItem x:Name="formatBarSubItem" Content="Format"> <dxb:BarSubItem.ItemLinks> <dxb:BarCheckItemLink BarItemName="boldBarCheckItem" /> </dxb:BarSubItem.ItemLinks> </dxb:BarSubItem> </dxb:BarManager.Items> <dxb:BarManager.Bars> <dxb:Bar IsMainMenu="True" Caption="Main Menu" UseWholeRow="True"> <dxb:Bar.DockInfo> <dxb:BarDockInfo ContainerType="Top" /> </dxb:Bar.DockInfo> <dxb:Bar.ItemLinks> <dxb:BarSubItemLink BarItemName="fileBarSubItem" /> <dxb:BarSubItemLink BarItemName="formatBarSubItem" /> </dxb:Bar.ItemLinks> </dxb:Bar> <dxb:Bar Caption="Format" AllowCollapse="True"> <dxb:Bar.DockInfo> <dxb:BarDockInfo ContainerType="Left" /> </dxb:Bar.DockInfo> <dxb:Bar.ItemLinks> <dxb:BarCheckItemLink BarItemName="boldBarCheckItem" /> </dxb:Bar.ItemLinks> </dxb:Bar> </dxb:BarManager.Bars> <TextBox Text="Sample text" /> </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 |
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 //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region Bold 막대 체크 항목 체크 변경시 처리하기 - boldBarCheckItem_CheckChanged(sender, e) /// <summary> /// Bold 막대 체크 항목 체크 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void boldBarCheckItem_CheckChanged(object sender, ItemClickEventArgs e) { MessageBox.Show("'Bold' has been clicked: " + (sender as BarCheckItem).IsChecked.ToString()); } #endregion #region Exit 막대 버튼 항목 항목 클릭시 처리하기 - exitBarButtonItem_ItemClick(sender, e) /// <summary> /// Exit 막대 버튼 항목 항목 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void exitBarButtonItem_ItemClick(object sender, ItemClickEventArgs e) { MessageBox.Show("'Exit' has been clicked"); } #endregion } } |