Share via


BindableObject.SetValue Metodo

Definizione

Overload

SetValue(BindableProperty, Object)

Imposta il valore della proprietà associabile specificata.

SetValue(BindablePropertyKey, Object)

Imposta il valore della proprietà associabile specificata.

SetValue(BindableProperty, Object)

Imposta il valore della proprietà associabile specificata.

public:
 void SetValue(Microsoft::Maui::Controls::BindableProperty ^ property, System::Object ^ value);
public void SetValue (Microsoft.Maui.Controls.BindableProperty property, object value);
member this.SetValue : Microsoft.Maui.Controls.BindableProperty * obj -> unit
Public Sub SetValue (property As BindableProperty, value As Object)

Parametri

property
BindableProperty

Proprietà associabile in cui assegnare un valore.

value
Object

Il valore da impostare.

Eccezioni

Viene generata quando property è null.

Commenti

Se property è di sola lettura, non accadrà nulla.

Si applica a

SetValue(BindablePropertyKey, Object)

Imposta il valore della proprietà associabile specificata.

public:
 void SetValue(Microsoft::Maui::Controls::BindablePropertyKey ^ propertyKey, System::Object ^ value);
public void SetValue (Microsoft.Maui.Controls.BindablePropertyKey propertyKey, object value);
member this.SetValue : Microsoft.Maui.Controls.BindablePropertyKey * obj -> unit
Public Sub SetValue (propertyKey As BindablePropertyKey, value As Object)

Parametri

propertyKey
BindablePropertyKey

Chiave che identifica la proprietà associabile a cui assegnare il valore.

value
Object

Il valore da impostare.

Eccezioni

Viene generata quando propertyKey è null.

Generato quando la proprietà associabile identificata da propertyKey è di sola lettura.

Commenti

Questo metodo e BindablePropertyKey sono utili per implementare BindableProperties con accesso in scrittura limitato. L'accesso in scrittura è limitato all'ambito di BindablePropertyKey.

Nell'esempio seguente viene illustrato come dichiarare bindableProperty con l'accesso in scrittura "interno".

class MyBindable : BindableObject
{
  internal static readonly BindablePropertyKey MyPropertyKey = 
    BindableProperty.CreateReadOnly<MyBindable, string> (w => w.My, default(string));
  public static readonly BindableProperty MyProperty = MyPropertyKey.BindableProperty;

  public string My {
    get { return (string)GetValue (MyProperty); }
    internal set { SetValue (MyPropertyKey, value); } 
  }
}

Si applica a