Programming/WPF
[WPF, Silverlight] UserControl의 Binding에 필요한 DependencyProperty 생성하기
홍상길
2012. 10. 19. 15:54
Behind Code에서 Binding을 구현하기 위해서는 Binding할 객체에 DependencyProperty가 생성되어 있어야 한다.
DependencyProperty를 구현하기 위해서는 대략 아래 3가지가 필요하다.
[Property]
public string TItle
{
get { return (string)GetValue(TItleProperty); }
set { SetValue(TItleProperty, value); }
}
{
get { return (string)GetValue(TItleProperty); }
set { SetValue(TItleProperty, value); }
}
[DependencyProperty]
public static readonly DependencyProperty TitleProperty =
DependencyProperty.Register("Title", typeof(string), typeof(TESTClass), new PropertyMetadata(TESTClass.TitlePropertyChangedCallback));
DependencyProperty.Register("Title", typeof(string), typeof(TESTClass), new PropertyMetadata(TESTClass.TitlePropertyChangedCallback));
[Callback function] : 값이 변경될때 발생 되는 이벤트
public static void TitlePropertyChangedCallback(
DependencyObject controlInstance, DependencyPropertyChangedEventArgs e)
{
}
DependencyObject controlInstance, DependencyPropertyChangedEventArgs e)
{
}