■ NavBarControl 클래스의 네비게이션 패인 뷰에서 활성화 시킴으로써 그룹을 탐색하는 방법을 보여준다.
▶ 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:dxn="http://schemas.devexpress.com/winfx/2008/xaml/navbar" Width="800" Height="600" Title="네비게이션 패인 뷰에서 활성화 시킴으로써 그룹 탐색하기" FontFamily="나눔고딕코딩" FontSize="16"> <DockPanel> <StackPanel Orientation="Horizontal" DockPanel.Dock="Top"> <Button x:Name="firstButton" Command="dxn:NavBarCommands.SetActiveGroup" CommandTarget="{Binding Path=View, ElementName=navBarControl}" CommandParameter="{Binding ElementName=firstNavBarGroup}"> First Group </Button> <Button x:Name="nextButton" Click="button_Click"> Next Group </Button> <Button x:Name="previousButton" Click="button_Click"> Prev Group </Button> <Button x:Name="lastButton" Command="dxn:NavBarCommands.SetActiveGroup" CommandTarget="{Binding Path=View, ElementName=navBarControl}" CommandParameter="{Binding ElementName=lastNavBarGroup}"> Last Group </Button> </StackPanel> <dxn:NavBarControl Name="navBarControl"> <dxn:NavBarControl.View> <dxn:NavigationPaneView ActiveGroupChanged="navigationPaneView_ActiveGroupChanged" /> </dxn:NavBarControl.View> <dxn:NavBarControl.Groups> <dxn:NavBarGroup x:Name="firstNavBarGroup" Header="Group1"> <dxn:NavBarItem>Item1</dxn:NavBarItem> </dxn:NavBarGroup> <dxn:NavBarGroup Header="Group2"> <dxn:NavBarItem>Item1</dxn:NavBarItem> <dxn:NavBarItem>Item2</dxn:NavBarItem> </dxn:NavBarGroup> <dxn:NavBarGroup Header="Group3"> <dxn:NavBarItem>Item1</dxn:NavBarItem> <dxn:NavBarItem>Item2</dxn:NavBarItem> <dxn:NavBarItem>Item3</dxn:NavBarItem> </dxn:NavBarGroup> <dxn:NavBarGroup x:Name="lastNavBarGroup" Header="Group4"> <dxn:NavBarItem>Item1</dxn:NavBarItem> <dxn:NavBarItem>Item2</dxn:NavBarItem> <dxn:NavBarItem>Item3</dxn:NavBarItem> <dxn:NavBarItem>Item4</dxn:NavBarItem> </dxn:NavBarGroup> </dxn:NavBarControl.Groups> </dxn:NavBarControl> </DockPanel> </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.NavBar; namespace TestProject { /// <summary> /// 메인 윈도우 /// </summary> public partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainWindow() /// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeComponent(); SetButton(); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private //////////////////////////////////////////////////////////////////////////////// Event #region 버튼 클릭시 처리하기 - button_Click(sender, e) /// <summary> /// 버튼 클릭시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void button_Click(object sender, RoutedEventArgs e) { int activeGroupIndex = this.navBarControl.Groups.IndexOf(this.navBarControl.ActiveGroup); if(sender == this.nextButton) { this.navBarControl.ActiveGroup = this.navBarControl.Groups[activeGroupIndex + 1]; } if(sender == this.previousButton) { this.navBarControl.ActiveGroup = this.navBarControl.Groups[activeGroupIndex - 1]; } } #endregion #region 네비게이션 패인 뷰 활성 그룹 변경시 처리하기 - navigationPaneView_ActiveGroupChanged(sender, e) /// <summary> /// 네비게이션 패인 뷰 활성 그룹 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void navigationPaneView_ActiveGroupChanged(object sender, NavBarActiveGroupChangedEventArgs e) { SetButton(); } #endregion //////////////////////////////////////////////////////////////////////////////// Function #region 버튼 설정하기 - SetButton() /// <summary> /// 버튼 설정하기 /// </summary> private void SetButton() { this.nextButton.IsEnabled = !(this.navBarControl.Groups.IndexOf(this.navBarControl.ActiveGroup) == this.navBarControl.Groups.Count - 1); this.previousButton.IsEnabled = !(this.navBarControl.Groups.IndexOf(this.navBarControl.ActiveGroup) == 0); } #endregion } } |