BindableObject.SetValue Méthode

Définition

Surcharges

SetValue(BindableProperty, Object)

Définit la valeur de la propriété pouvant être liée spécifiée.

SetValue(BindablePropertyKey, Object)

Définit la valeur de la propriété pouvant être liée spécifiée.

SetValue(BindableProperty, Object)

Définit la valeur de la propriété pouvant être liée spécifiée.

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)

Paramètres

property
BindableProperty

Propriété pouvant être liée à laquelle affecter une valeur.

value
Object

Valeur à définir.

Exceptions

Levée lorsque property est null.

Remarques

Si property est en lecture seule, rien ne se passera.

S’applique à

SetValue(BindablePropertyKey, Object)

Définit la valeur de la propriété pouvant être liée spécifiée.

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)

Paramètres

propertyKey
BindablePropertyKey

Clé qui identifie la propriété pouvant être liée à laquelle affecter la valeur.

value
Object

Valeur à définir.

Exceptions

Levée lorsque propertyKey est null.

Levée lorsque la propriété pouvant être liée identifiée par propertyKey est en lecture seule.

Remarques

Cette méthode et BindablePropertyKey sont utiles pour implémenter BindableProperties avec un accès en écriture limité. L’accès en écriture est limité à l’étendue de BindablePropertyKey.

L’exemple suivant montre comment déclarer une bindableProperty avec un accès en écriture « interne ».

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); } 
  }
}

S’applique à