description | title | ms.assetid | ms.date | ms.topic | keywords | ms.localizationpriority |
---|---|---|---|---|---|---|
Learn how you can use the x:Null markup extension in XAML markup to specify a null value for a property. |
xNull markup extension |
E6A4038E-4ADA-4E82-9824-582FC16AB037 |
02/08/2017 |
article |
windows 10, uwp |
medium |
In XAML markup, specifies a null value for a property.
<object property="{x:Null}" .../>
null is the null reference keyword for C# and C++. The Microsoft Visual Basic keyword for a null reference is Nothing.
The initial default value can vary between dependency properties, and it is not necessarily null. Further, many dependency properties will not accept null as a value (whether through markup or code) due to their internal implementation. In such cases, setting a XAML attribute value with {x:Null} can result in a parser exception.
Some Windows Runtime types are nullable. In cases where a nullable type does not already have null as the default, you could use {x:Null} in XAML to set to the null value. If using Visual C++ component extensions (C++/CX), nullable types are represented as Platform::IBox<T>. If using Microsoft .NET languages, nullable types are represented as Nullable<T>.