첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
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">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*"    />
        </Grid.RowDefinitions>
        <Button x:Name="toggleGroupStateButton"
            Grid.Row="0"
            Margin="10 10 10 5"
            Click="toggleGroupStateButton_Click">Toggle Group State</Button>
        <dxn:NavBarControl x:Name="navBarControl"
            Grid.Row="1"
            Margin="10 5 10 10">
            <dxn:NavBarControl.Groups>
                <dxn:NavBarGroup Header="Group1">
                    <dxn:NavBarItem>Item1</dxn:NavBarItem>
                    <dxn:NavBarItem>Item2</dxn:NavBarItem>
                </dxn:NavBarGroup>
                <dxn:NavBarGroup
                    IsExpanded="False"
                    Header="Group2">
                    <dxn:NavBarItem>Item1</dxn:NavBarItem>
                    <dxn:NavBarItem>Item2</dxn:NavBarItem>
                    <dxn:NavBarItem>Item3</dxn:NavBarItem>
                </dxn:NavBarGroup>
                <dxn:NavBarGroup Header="Group3">
                    <dxn:NavBarItem>Item1</dxn:NavBarItem>
                    <dxn:NavBarItem>Item2</dxn:NavBarItem>
                </dxn:NavBarGroup>
            </dxn:NavBarControl.Groups>
            <dxn:NavBarControl.View>
                <dxn:ExplorerBarView />
            </dxn:NavBarControl.View>
        </dxn:NavBarControl>
    </Grid>
</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();
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region Toggle Group State 버튼 클릭시 처리하기 - toggleGroupStateButton_Click(sender, e)

        /// <summary>
        /// Toggle Group State 버튼 클릭시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void toggleGroupStateButton_Click(object sender, RoutedEventArgs e)
        {
            for(int i = 0; i < this.navBarControl.Groups.Count; i++)
            {
                NavBarGroup navBarGroup = this.navBarControl.Groups[i];

                navBarGroup.IsExpanded = !navBarGroup.IsExpanded;
            }
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요