■ Binding 태그 확장을 사용하는 방법을 보여준다.
▶ Dog.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
/// <summary> /// 개 /// </summary> public class Dog { //////////////////////////////////////////////////////////////////////////////////////////////////// Property ////////////////////////////////////////////////////////////////////////////////////////// Public #region 개 이름 - DogName /// <summary> /// 개 이름 /// </summary> public string DogName { get; set; } #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 |
<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:TestSilverlightApplication" mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="300"> <Grid> <Grid.Resources> <local:Dog x:Key="DogKey" DogName="Spot" /> </Grid.Resources> <TextBlock Text="{Binding DogName, Source={StaticResource DogKey}, Mode=OneTime}" /> <!--TextBlock DataContext="{StaticResource DogKey}" Text="{Binding DogName, Mode=OneTime}" /--> </Grid> </UserControl> |