Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7041171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:00:24+00:00 2026-05-28T02:00:24+00:00

My application generates XAML files from in-memory objects using the built-in .NET solution: System.XamlServices.Save(Stream,

  • 0

My application generates XAML files from in-memory objects using the built-in .NET solution: System.XamlServices.Save(Stream, Object)
However, the XAML I get is polluted badly. All properties are always serialized. Is there a way that to tell the XAML serializer to ignore properties that hold their default values? (I have almost full control over the classes that are serialized.)

Expression Blend solves this wonderfully: if we do not change a property, the generated XAML file will not contain it, at all. The resulted XAML is not cluttered with all the possible properties and their default values and does not look like the regular autogenerated mess. I would like to have beautiful XAML, too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:00:25+00:00Added an answer on May 28, 2026 at 2:00 am

    To do this with just one object:

    Once:

    • Make a new object with default properties
    • Serialize it to XAML
    • Load it into an XML DOM
    • Recurse thru each child and sub-child node
    • Save each into a dictionary with the key the XPath of the node, the value the innerXML. Obviously, if you have nodes with the same path this won’t work, you’ll have to qualify them. But in such case you’d probably want to never prune those anyway.
    • You don’t need that object anymore. Pitch it, keep the Dictionary around.

    For each object:

    • Serialize that object to XAML
    • Loadit into an XML DOM
    • Recurse thru each child and sub-child node
    • Look up each XPath in the dictionary.
    • If the innerXML is the same, note this in a list of nodes that should be afraid.
    • When done recursing, show those nodes why they are afraid – DELETE them!
    • The DOM should have beautiful XAML in it.

    I had you same the XPath in the dictionary to make nested objects work better. It depends what your objects are and how they are nested for me to be able to speak to that, however. good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a custom-built inhouse application that generates a standard set of reports on
My ASP.Net application generates an <asp:Table> from the codebehind. What I need is for
The asp.net mvc web application generates log-files and cache files within an 3rd party
My (C#, .NET 3.5) application generates files and, in addition to raising events that
My application generates some .xls files and until now I was using PHPExcel lib
My web application generates pdf files and either e-mails or faxes them to our
Background: we have an application that generates reports from HTML (that may or may
My .Net Windows Forms application generates a PDF report, which I want to show
I am building a web application using Yii. The application generates MS-Word documents. Does
I'm making a theme editor for a WPF application. I generate XAML files dynamically,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.