[WPF] UserControl 의 DependencyProperty 프로퍼티 사용해서 호출하기
WPF 2007. 11. 30. 17:40 | public partial class UserControl1 : UserControl
{
public static DependencyProperty InputTextProperty;
public UserControl1()
{
InitializeComponent();
//
InputTextProperty = DependencyProperty.Register("InputText", typeof(string),
typeof(UserControl1),
new FrameworkPropertyMetadata("none", new PropertyChangedCallback(OnInputTextChanged)));
}
public string InputText
{
set { SetValue(InputTextProperty, value); }
get { return (string)GetValue(InputTextProperty); }
}
private void OnInputTextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
TextBlock tb = this.FindName("txtShow") as TextBlock;
tb.Text = InputText;
}
}
관련코드 :