첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.

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="NavBarControl을 단순 DataTable에 바인딩 하기"
    FontFamily="나눔고딕코딩"
    FontSize="12">
    <Grid>
        <dxn:NavBarControl x:Name="navBarControl"
            ItemsSource="{Binding}"
            GroupDescription="Group">
            <dxn:NavBarControl.Resources>
                <Style TargetType="dxn:NavBarGroup">
                    <Setter Property="Header" Value="{Binding}" />
                </Style>
                <Style TargetType="dxn:NavBarItem">
                    <Setter Property="Content" Value="{Binding Path=Item}" />
                </Style>
            </dxn:NavBarControl.Resources>
        </dxn:NavBarControl>
    </Grid>
</Window>

 

728x90

 

▶ MainWindow.xaml.cs

using System.Data;
using System.Windows;

namespace TestProject
{
    /// <summary>
    /// 메인 윈도우
    /// </summary>
    public partial class MainWindow : Window
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainWindow()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("Group", typeof(string));
            dataTable.Columns.Add("Item" , typeof(string));

            for(int i = 1; i <= 2; i++)
            {
                for(int j = 1; j <= 3; j++)
                {
                    dataTable.Rows.Add
                    (
                        new object[]
                        {
                            "Group " + i.ToString(),
                            "Item "  + i.ToString() + "-" + j.ToString()
                        }
                    );
                }
            }

            DataContext = dataTable;
        }

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

댓글을 달아 주세요