After I tried different things, I accidentally found myself on a solution. I set XmlElementAttribute.IsNullable to true, as in the previous answer.
[System.Xml.Serialization.XmlElementAttribute(ElementName = "Confirm", IsNullable=true)] public ConfirmType Confirm { get { return this.confirmField; } set { this.confirmField = value; this.RaisePropertyChanged("Confirm"); } }
Then, when you set the type of confirmation in the code, I used the default constructor instead of setting Confirm to null.
retval.ConfirmBODDataArea.Confirm = new ConfirmType();
This is serialized as <star:Confirm/>
Chris lunt
source share