BindingOperations.SetBinding メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
BindingExpressionBaseの新しいインスタンスを作成し、指定したバインディング ターゲット プロパティに関連付けます。
public:
static System::Windows::Data::BindingExpressionBase ^ SetBinding(System::Windows::DependencyObject ^ target, System::Windows::DependencyProperty ^ dp, System::Windows::Data::BindingBase ^ binding);
public static System.Windows.Data.BindingExpressionBase SetBinding(System.Windows.DependencyObject target, System.Windows.DependencyProperty dp, System.Windows.Data.BindingBase binding);
static member SetBinding : System.Windows.DependencyObject * System.Windows.DependencyProperty * System.Windows.Data.BindingBase -> System.Windows.Data.BindingExpressionBase
Public Shared Function SetBinding (target As DependencyObject, dp As DependencyProperty, binding As BindingBase) As BindingExpressionBase
パラメーター
- target
- DependencyObject
バインディングのバインディング ターゲット。
バインディングのターゲット プロパティ。
- binding
- BindingBase
バインディングを記述する BindingBase オブジェクト。
返品
指定したプロパティに対して作成され、関連付けられている BindingExpressionBase のインスタンス。 BindingExpressionBase クラスは、BindingExpression、MultiBindingExpression、およびPriorityBindingExpressionの基底クラスです。
例外
binding パラメーターをnullすることはできません。
例
次の例は、このメソッドを使用してバインドを設定する方法を示しています。 この例では、 myNewBindDef はバインディングを記述する Binding オブジェクトです。 バインディング ターゲットは、myDateText クラスのインスタンスであるTextBlock。
// myDatetext is a TextBlock object that is the binding target object
BindingOperations.SetBinding(myDateText, TextBlock.TextProperty, myNewBindDef);
BindingOperations.SetBinding(myDateText, TextBlock.ForegroundProperty, myNewBindDef);
' myDatetext is a TextBlock object that is the binding target object
BindingOperations.SetBinding(myDateText, TextBlock.TextProperty, myNewBindDef)
BindingOperations.SetBinding(myDateText, TextBlock.ForegroundProperty, myNewBindDef)
注釈
このメソッドは、 BindingExpressionBase の新しいインスタンスを作成し、そのインスタンスを特定のオブジェクトの指定された依存関係プロパティに関連付けます。 このメソッドは、独自の SetBinding メソッドを公開しない可能性がある任意の DependencyObject にバインドをアタッチする方法です。