■ BarManager 클래스에서 BarStaticItem 항목을 생성하는 방법을 보여준다.
▶ 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 |
<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="BarStaticItem 항목 생성하기" 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" /> <dxb:BarButtonItem x:Name="pasteBarButtonItem" Content="Paste" Glyph="pack://application:,,,/Image/paste16x16.png" /> <dxb:BarButtonItem x:Name="undoBarButtonItem" Content="Undo" Glyph="pack://application:,,,/Image/undo16x16.png" /> <dxb:BarButtonItem x:Name="redoBarButtonItem" Content="Redo" Glyph="pack://application:,,,/Image/redo16x16.png" /> <dxb:BarStaticItem x:Name="documentNameBarStaticItem" Content="Document Name : " AutoSizeMode="Fill" /> <dxb:BarStaticItem x:Name="itemLineBarStaticItem" Content="Line : " /> </dxb:BarManager.Items> <dxb:BarManager.Bars> <dxb:Bar x:Name="mainMenuBar" IsMainMenu="True" UseWholeRow="True" Caption="Main Menu"> <dxb:Bar.DockInfo> <dxb:BarDockInfo ContainerType="Top" Row="0" /> </dxb:Bar.DockInfo> <dxb:Bar.ItemLinks> <dxb:BarButtonItemLink BarItemName="undoBarButtonItem" /> <dxb:BarButtonItemLink BarItemName="redoBarButtonItem" /> <dxb:BarButtonItemLink BarItemName="copyBarButtonItem" /> <dxb:BarButtonItemLink BarItemName="pasteBarButtonItem" /> </dxb:Bar.ItemLinks> </dxb:Bar> <dxb:Bar x:Name="statusBar" IsStatusBar="True" UseWholeRow="True" Caption="Status Bar"> <dxb:Bar.DockInfo> <dxb:BarDockInfo ContainerType="Bottom" /> </dxb:Bar.DockInfo> <dxb:Bar.ItemLinks> <dxb:BarStaticItemLink BarItemName="itemLineBarStaticItem" /> <dxb:BarStaticItemLink BarItemName="documentNameBarStaticItem" /> </dxb:Bar.ItemLinks> </dxb:Bar> </dxb:BarManager.Bars> <RichTextBox x:Name="richTextBox" /> </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 |
using System.Windows; namespace TestProject { /// <summary> /// 메인 윈도우 /// </summary> public partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainWindow() /// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeComponent(); this.richTextBox.SelectionChanged += richTextBox_SelectionChanged; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 리치 텍스트 박스 선택 변경시 처리하기 - richTextBox_SelectionChanged(sender, e) /// <summary> /// 리치 텍스트 박스 선택 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void richTextBox_SelectionChanged(object sender, RoutedEventArgs e) { int line = 0; int column = 0; this.richTextBox.CaretPosition.GetLineStartPosition(-100000, out line); column = this.richTextBox.CaretPosition.GetOffsetToPosition(this.richTextBox.CaretPosition.GetLineStartPosition(0)); this.itemLineBarStaticItem.Content = "Line : " + (-line).ToString() + " Position : " + (-column).ToString(); } #endregion } } |