Welcome to WindowsClient.net | Sign in | Join

Rob Relyea - XAMLified

WPF, Silverlight and XAML

FAQ: how to prevent {x:Null} from being written by XAML writer
Internal thread that may be of use to more people: 

Question From: Microsoft Developer

Is there a way to configure XAML writer (XamlWriter.Save() or XamlServices.Save()) to not to serialize null properties. Right now I get "{x:Null}" written for them?

 

Answer From: XAML Team Developer

You need to attribute the affected properties with [DefaultValue(null)]

  

Mike Hillberg's "Being Written by XamlWriter" is a good read for this kind of info

 

--

Published Tuesday, June 02, 2009 4:46 AM by Rob_Relyea
Filed under:

Comments

# re: FAQ: how to prevent {x:Null} from being written by XAML writer@ Tuesday, June 02, 2009 1:03 PM

Thanks, very interesting. Recently I've spend some time implementing the opposite behavior within a custom XAML serializer. We needed to provide "x:Null" value...

# re: FAQ: how to prevent {x:Null} from being written by XAML writer@ Tuesday, June 02, 2009 2:57 PM

Denis-

Would love to know why you needed to write down x:Null if that is the default value for a property?

Thanks, Rob

# Dew Drop - June 3, 2009 | Alvin Ashcraft's Morning Dew@ Wednesday, June 03, 2009 9:37 AM

Pingback from  Dew Drop - June 3, 2009 | Alvin Ashcraft's Morning Dew

# re: FAQ: how to prevent {x:Null} from being written by XAML writer@ Wednesday, June 03, 2009 10:09 AM

Sorry to misuse your comments section, but this post on Stack Overflow "How unique is Xaml?" might really benefit from your input:

stackoverflow.com/.../944964

Great blog btw ;)

by JC

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Page view counter