NullProperty Sample

Back to summary

Source

using System.ComponentModel;

namespace XmlSerializersTest.Samples
{
    [Title("Null property")]
    public class NullProperty
    {
        public string NullString { get; set; }

        [DefaultValue(null)]
        public string NullStringWithDefault { get; set; }

        public MyClass CustomClassProperty { get; set; }
    }

    public class MyClass
    {
        public int SomeProperty { get; set; }
    }
}

XAML Serializer

<NullProperty NullString="{x:Null}" CustomClassProperty="{x:Null}" xmlns="clr-namespace:XmlSerializersTest.Samples;assembly=XmlSerializersTest" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" />