■ Binding 클래스 사용하기

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

Dog.cs

 

/// <summary>

///

/// </summary>

public class Dog

{

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

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

 

    #region 개 이름 - DogName

 

    /// <summary>

    /// 개 이름

    /// </summary>

    public string DogName { get; set; }

 

    #endregion

}

 

MainPage.xaml

 

<Grid x:Name="grid"

    Background="White">

    <TextBlock x:Name="textBlock"

        Text="Test" />

</Grid>

 

MainPage.xaml.cs

 

using System.Windows.Data;

 

...

 

Dog dog = new Dog();

 

dog.DogName = "Spot";

 

...

 

Binding binding = new Binding();

 

binding.Path   = new PropertyPath("DogName");

binding.Mode   = BindingMode.OneTime;

binding.Source = dog; // 또는 textBlock.DataContext = dog;

 

...

 

this.textBlock.SetBinding(TextBlock.TextProperty, binding);

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

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요