첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
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: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>

 

728x90

 

▶ MainWindow.xaml.cs

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
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요