첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ NavBarControl 클래스 : 단순 DataTable에 바인딩 하기

----------------------------------------------------------------------------------------------------


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>

 

 

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

    }

}

 

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요