■ Binding 태그 확장 사용하기

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

C#

 

/// <summary>

///

/// </summary>

public class Dog

{

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

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

 

    #region 개 이름 - DogName

 

    /// <summary>

    /// 개 이름

    /// </summary>

    public string DogName { get; set; }

 

    #endregion

}

 

XAML

 

<UserControl x:Class="TestSilverlightApplication.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>

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

Posted by 사용자 icodebroker
TAG