FrameworkContentElement.SetBinding Yöntem
Tanım
Belirtilen bağımlılık özelliği için bu öğeye bir bağlama ekler.Attaches a binding to this element for the specified dependency property.
Aşırı Yüklemeler
SetBinding(DependencyProperty, String) |
Bu öğeye, girilen kaynak özelliği adına veri kaynağı için bir yol niteliği olarak bir bağlama ekler.Attaches a binding to this element, based on the provided source property name as a path qualification to the data source. |
SetBinding(DependencyProperty, BindingBase) |
Bu öğeye, belirtilen bağlama nesnesine göre bir bağlama ekler.Attaches a binding to this element, based on the provided binding object. |
SetBinding(DependencyProperty, String)
Bu öğeye, girilen kaynak özelliği adına veri kaynağı için bir yol niteliği olarak bir bağlama ekler.Attaches a binding to this element, based on the provided source property name as a path qualification to the data source.
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
Parametreler
Bağlantılı özelliği tanımlar.Identifies the bound property.
- path
- String
Kaynak özelliği adı veya bağlama için kullanılan özelliğin yolu.The source property name or the path to the property used for the binding.
Döndürülenler
Bağlamanın koşullarını kaydeder.Records the conditions of the binding. Bu dönüş değeri, hata denetimi için yararlı olabilir.This return value can be useful for error checking.
Örnekler
Aşağıdaki örnek, bir öğe üzerinde bir bağlamayı Paragraph , yeni bir özel veri nesnesi oluşturup bu nesneyi olarak kurarak DataContext ve içindeki bir özelliğe bağlama yolunu ayarlayarak ayarlar.The following example sets a binding on a Paragraph element, by creating a new custom data object, establishing that object as DataContext, and setting the binding path to a property within it.
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")
Açıklamalar
Bu yöntem, BindingOperations.SetBinding geçerli örneği olarak geçen DependencyObject ve Binding belirtilen parametreye göre yeni bir oluşturan çağırmak için kullanışlı bir yöntemdir path
.This method is a convenience method for calling BindingOperations.SetBinding, which passes the current instance as the DependencyObject, and creates a new Binding based on the provided path
parameter. Bu imza, basit bir varsayılan bağlama oluşturuyorsanız daha uygundur.This signature is more convenient if you are establishing a simple default binding. Varsayılan olmayan koşullara bağlama özellikleri belirtmeniz veya bir veya kullanmak istiyorsanız, MultiBinding PriorityBinding imzayı kullanmanız gerekir SetBinding(DependencyProperty, BindingBase) .If you need to specify any binding properties to non-default conditions, or want to use a MultiBinding or PriorityBinding,you should use the SetBinding(DependencyProperty, BindingBase) signature.
Şunlara uygulanır
SetBinding(DependencyProperty, BindingBase)
Bu öğeye, belirtilen bağlama nesnesine göre bir bağlama ekler.Attaches a binding to this element, based on the provided binding object.
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
Parametreler
Bağlantılı özelliği tanımlar.Identifies the bound property.
- binding
- BindingBase
Bir veri bağlamayı temsil eder.Represents a data binding.
Döndürülenler
Bağlamanın koşullarını kaydeder.Records the conditions of the binding. Bu dönüş değeri, hata denetimi için yararlı olabilir.This return value can be useful for error checking.
Örnekler
Aşağıdaki örnek Paragraph , yeni bir oluşturma Binding ve kaynağı yeni oluşturulan bir nesneye ayarlayarak bir öğe üzerinde bir bağlamayı ayarlar DateTime
.The following example sets a binding on a Paragraph element, by creating a new Binding and setting the source to a newly built DateTime
object.
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)
Açıklamalar
Bu yöntem, çağrısı için, BindingOperations.SetBinding geçerli örneği olarak geçen kolay bir yöntemdir DependencyObject .This method is a convenience method for calling BindingOperations.SetBinding, which passes the current instance as the DependencyObject.