FrameworkContentElement.SetBinding メソッド

定義

指定した依存関係プロパティのバインディングをこの要素にアタッチします。

オーバーロード

名前 説明
SetBinding(DependencyProperty, String)

指定されたソース プロパティ名に基づいて、データ ソースへのパス修飾として、この要素にバインドをアタッチします。

SetBinding(DependencyProperty, BindingBase)

指定されたバインド オブジェクトに基づいて、この要素にバインドをアタッチします。

SetBinding(DependencyProperty, String)

指定されたソース プロパティ名に基づいて、データ ソースへのパス修飾として、この要素にバインドをアタッチします。

public:
 System::Windows::Data::BindingExpression ^ SetBinding(System::Windows::DependencyProperty ^ dp, System::String ^ path);
public System.Windows.Data.BindingExpression SetBinding(System.Windows.DependencyProperty dp, string path);
member this.SetBinding : System.Windows.DependencyProperty * string -> System.Windows.Data.BindingExpression
Public Function SetBinding (dp As DependencyProperty, path As String) As BindingExpression

パラメーター

dp
DependencyProperty

バインドされたプロパティを識別します。

path
String

バインディングに使用されるソース プロパティ名またはプロパティへのパス。

返品

バインディングの条件を記録します。 この戻り値は、エラー チェックに役立ちます。

次の例では、新しいカスタム データ オブジェクトを作成し、そのオブジェクトをDataContextとして確立し、その中のプロパティにバインド パスを設定することで、Paragraph要素にバインドを設定します。

MyData myDataObject = new MyData();
myflowdocument.DataContext = myDataObject;
introParagraph.SetBinding(Paragraph.TagProperty, "CustomData");
Dim myDataObject As New MyData()
myflowdocument.DataContext = myDataObject
introParagraph.SetBinding(Paragraph.TagProperty, "CustomData")

注釈

このメソッドは、現在のインスタンスをDependencyObjectとして渡し、指定されたpath パラメーターに基づいて新しいBindingを作成するBindingOperations.SetBindingを呼び出すための便利なメソッドです。 この署名は、単純な既定のバインドを確立する場合に便利です。 既定以外の条件にバインド プロパティを指定する必要がある場合、または MultiBinding または PriorityBindingを使用する場合は、 SetBinding(DependencyProperty, BindingBase) 署名を使用する必要があります。

適用対象

SetBinding(DependencyProperty, BindingBase)

指定されたバインド オブジェクトに基づいて、この要素にバインドをアタッチします。

public:
 System::Windows::Data::BindingExpressionBase ^ SetBinding(System::Windows::DependencyProperty ^ dp, System::Windows::Data::BindingBase ^ binding);
public System.Windows.Data.BindingExpressionBase SetBinding(System.Windows.DependencyProperty dp, System.Windows.Data.BindingBase binding);
member this.SetBinding : System.Windows.DependencyProperty * System.Windows.Data.BindingBase -> System.Windows.Data.BindingExpressionBase
Public Function SetBinding (dp As DependencyProperty, binding As BindingBase) As BindingExpressionBase

パラメーター

dp
DependencyProperty

バインドされたプロパティを識別します。

binding
BindingBase

データ バインディングを表します。

返品

バインディングの条件を記録します。 この戻り値は、エラー チェックに役立ちます。

次の例では、新しいBindingを作成し、新しくビルドされたDateTime オブジェクトにソースを設定することで、Paragraph要素にバインドを設定します。

DateTime myDataObject = new DateTime();
Binding myBinding = new Binding();
myBinding.Source = myDataObject;
introParagraph.SetBinding(Paragraph.TagProperty, myBinding);
Dim myDataObject As New Date()
Dim myBinding As New Binding()
myBinding.Source = myDataObject
introParagraph.SetBinding(Paragraph.TagProperty, myBinding)

注釈

このメソッドは、現在のインスタンスをDependencyObjectとして渡すBindingOperations.SetBindingを呼び出すための便利なメソッドです。

適用対象