Silverlightアプリケーションにtextboxes(1)を含む2つのユーザーコントロールがあります。これらのテキストボックスの1つに書き込みを開始するときに、これらのテキストボックスを同期するにはどうすればよいですか。
1 に答える
0
テキストボックスの値を変更する依存関係プロパティを各コントロールに作成し、コントロールを他の値にバインドします。
例
public static readonly DependencyProperty InnerTextProperty=
DependencyProperty.Register(
"InnerText", typeof(string),
new PropertyMetadata(false, OnTextInput) );
public bool InnerText
{
get { return (bool)GetValue(InnerTextProperty); }
set { SetValue(InnerTextProperty, value); }
}
private static void OnTextInput(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
YourControl c = obj as YourControl
if(c != null)
{
c._innerTextBox.Text = e.Value;
}
}
于 2013-02-21T14:23:33.100 に答える