■ DesignData 태그 확장을 사용하는 방법을 보여준다.
▶ SampleCustomer.xaml
1 2 3 4 5 6 7 8 |
<local:Customer xmlns:local="clr-namespace:TestProject" FirstName="Syed" LastName="Abbas" Age="23" CustomerID="E7181DC6-3F9E-45A4-A5F7-AC0B119D1FD8" /> |
※빌드 작업 : DesignData
▶ SampleCustomers.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<local:CustomerCollection xmlns:local="clr-namespace:TestProject" > <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> |
※ 빌드 작업 : DesignData
▶ Customer.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
using System; namespace TestProject { /// <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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
using System.Collections.Generic; namespace TestProject { /// <summary> /// 고객 컬렉션 /// </summary> public class CustomerCollection : List<Customer> { #region 생성자 - CustomerCollection /// <summary> /// 생성자 /// </summary> public CustomerCollection() { } #endregion } } |
▶ MainPage.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
<UserControl x:Class="TestProject.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:TestProject" 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> |