ExpressionContext.PresetValue Property

Definition

Gets the preset value of an expression.

public:
 property System::Object ^ PresetValue { System::Object ^ get(); };
public object PresetValue { get; }
public object? PresetValue { get; }
member this.PresetValue : obj
Public ReadOnly Property PresetValue As Object

Property Value

The preset value of this expression, or null if not assigned.

Remarks

Contains the preset value of an expression, should one exist. For example, if the expression is a property reference expression referring to the Controls property of a Button, the PresetValue property contains the instance of the Controls property. This is because the property is read-only and preset by the object to contain a value. On the other hand, a property such as Text or Visible does not have a preset value and therefore the PresetValue property returns null.

The following C# code shows how serializers can use this information to guide serialization.

Padding p = new Padding();  
p.Left = 5;  
button1.Padding = p;  

button1.Padding.Left = 5;  

The serializer of the Padding structure needs to be informed if it should generate the first or second form. The first form is generated by default. The second form is only generated if there is an ExpressionContext on the context stack that contains a PresetValue equal to the value of the Padding currently being serialized.

Applies to

See also