■ DesignData 태그 확장 사용하기

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

SampleCustomer.xaml (빌드 작업 : DesignData)

 

<local:Customer

    xmlns:local="clr-namespace:SampleDataApplication"

    FirstName="Syed"

    LastName="Abbas"

    Age="23"

    CustomerID="E7181DC6-3F9E-45A4-A5F7-AC0B119D1FD8" />

 

SampleCustomers.xaml (빌드 작업 : DesignData)

 

<local:CustomerCollection

    xmlns:local="clr-namespace:SampleDataApplication" >

    <local:Customer

        FirstName="Syed"

        LastName="Abbas"

        Age="23"

        CustomerID="E7181DC6-3F9E-45A4-A5F7-AC0B119D1FD8" />

    <local:Customer

        FirstName="Brenda"

        LastName="Diaz"

        Age="55"

        CustomerID="BB638D72-8B72-495A-B0F9-79F37964BBAE" />

    <local:Customer

        FirstName="Lori"

        LastName="Kane"

        Age="17"

        CustomerID="B168D811-5548-4D28-8171-318F9A4D7219" />

</local:CustomerCollection>

 

Customer.cs

 

using System;

 

namespace SampleDataApplication

{

    /// <summary>

    /// 고객

    /// </summary>

    public class Customer

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Property

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region 이름 - FirstName

 

        /// <summary>

        /// 이름

        /// </summary>

        public string FirstName { get; set; }

 

        #endregion

 

        #region 성 - LastName

 

        /// <summary>

        ///

        /// </summary>

        public string LastName { get; set; }

 

        #endregion

 

        #region 고객 ID - CustomerID

 

        /// <summary>

        /// 고객 ID

        /// </summary>

        public Guid CustomerID { get; set; }

 

        #endregion

 

        #region 나이 - Age

 

        /// <summary>

        /// 나이

        /// </summary>

        public int Age { get; set; }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor

        ////////////////////////////////////////////////////////////////////////////////////////// Public

        

        #region 생성자 - Customer()

 

        /// <summary>

        /// 생성자

        /// </summary>

        public Customer()

        {

        }

 

        #endregion

    }

}

 

CustomerCollection.cs

 

using System.Collections.Generic;

 

namespace SampleDataApplication

{

    /// <summary>

    /// 고객 컬렉션

    /// </summary>

    public class CustomerCollection : List<Customer>

    {

        #region 생성자 - CustomerCollection

 

        /// <summary>

        /// 생성자

        /// </summary>

        public CustomerCollection()

        {

        }

 

        #endregion

    }

}

 

XAML

 

<UserControl

    x:Class="SampleDataApplication.MainPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    xmlns:local="clr-namespace:SampleDataApplication"

    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"

    mc:Ignorable="d"

    d:DesignWidth="400"

    d:DesignHeight="300">

    <Grid

        x:Name="grid"

        Background="White"

        ShowGridLines="True">

        <Grid.RowDefinitions>

            <RowDefinition />

            <RowDefinition />

        </Grid.RowDefinitions>

        <StackPanel

            Grid.Row="0"

            d:DataContext="{d:DesignData Source=/DesignData/SampleCustomer.xaml}">

            <TextBox Text="{Binding FirstName}" />

        </StackPanel>

        <sdk:DataGrid

            Grid.Row="1"

            d:DataContext="{d:DesignData Source=/DesignData/SampleCustomers.xaml}"

            ItemsSource="{Binding}" />

    </Grid>

</UserControl>

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

Posted by 사용자 icodebroker
TAG