BindableObject.SetBinding(BindableProperty, BindingBase) 方法

定義

將繫結指派給屬性。

public void SetBinding (Xamarin.Forms.BindableProperty targetProperty, Xamarin.Forms.BindingBase binding);
member this.SetBinding : Xamarin.Forms.BindableProperty * Xamarin.Forms.BindingBase -> unit

參數

targetProperty
BindableProperty

要在其上設定繫結的 BindableProperty。

binding
BindingBase

要設定的繫結。

備註

下列範例示範如何將系結設定為 屬性:

var label = new Label ();
label.SetBinding (Label.TextProperty, new Binding ("Name"));
label.BindingContext = new {
    Name = "John Doe",
    Company = "Xamarin"
};

Debug.WriteLine (label.Text); // prints "John Doe"

適用於