-2

私はこれを持っています:

TextBlock MyText = new TextBlock();
String SomeWords;

これら2つのプロパティをバインドしたいのですが、文字列でそれを行う方法がわかりません:

Binding binding = new Binding();
binding.Path = new PropertyPath(MyText.Text);
BindingOperations.SetBinding(SomeWords, ???????, binding);

クエスチョンマークの位置に何を置くと思いますか?

タイ!!!

4

3 に答える 3

1
TextBlock MyText = new TextBlock();

Binding binding = new Binding();
binding.Path = new PropertyPath("Name"); //Name of the property in Datacontext
BindingOperations.SetBinding(MyText,TextBlock.TextProperty , binding);

他のオブジェクトのプロパティにバインドする場合は、そのオブジェクトに binding.Source を設定する必要があります。

于 2013-09-05T09:36:40.147 に答える