.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

XAML Serialization bug

Posted By:      Posted Date: August 29, 2010    Points: 0   Category :WPF
Hi all, I have this class public class XamlBugClass { List<string> myList = new List<string>(); public List<string> MyList { get { return myList; } set { myList = value; } } } this XAML <XamlBugClass xmlns="clr-namespace:WindowsFormsApplication1;assembly=WindowsFormsApplication1" > <XamlBugClass.MyList> <String xmlns="clr-namespace:System;assembly=mscorlib" >hello world</String> <String xmlns="clr-namespace:System;assembly=mscorlib" >hello world2</String> </XamlBugClass.MyList> </XamlBugClass> and I do this operation object t = XamlReader.Load(File.OpenRead("MySample.xaml")); string XAML = XamlWriter.Save(t); The Load just works perfect but when I get to the Save I get "Cannot serialize a generic type 'System.Collections.Generic.List`1[System.String]'."   This does not make sense at all, so I consider it a bug. Cheers, Tobias

View Complete Post

More Related Resource Links

XAML Serialization replacement

I've got an app where the user lays out a windows with various information displays.  To save the layout the window is serialized using XAML Serialization vial XAMLWriter.Save. the problem is all of the controls are user controls and as XAML Writer is"self contained" it serializes all the contents of the usercontrol as well.  You end up with the control, its resources, contextmenus and component controls being serialized. Does any one know of a solution to this problem so only the XAML for the user control only? I'd role my own version of this, but don't really know the best way to do so.   any help would be appreciated.  

XAML Serialization Problem


I try to save (serialize) a XAML document. The background is that the user of the application should be able to change the XAML document dynamically.

This works fine with some basic controls but as soon as I have a datagrid inside the XAML, non of this works:

System.Windows.Markup.XamlWriter.Save throws:

Cannot serialize a generic type 'System.Collections.ObjectModel.ObservableCollection`1[Microsoft.Windows.Controls.DataGridColumn]'.

System.Xaml.XamlServices.Save throws:

Constructor on type 'System.ComponentModel.ComponentConverter' not found.

I already found in forum that XAML does not fully support generics, however, is there a solution for this? I'm a bit confused because if XAML can be read dynamically it should also be possible to save it...

I use .NET Framework 4.

Thanks for reply... any suggestion is very welcome.

cider xaml serialization


I have a property that is of an abstract base class type.  This class has a typeconverter the can covert to and from string so that I can write xaml like so

<MyControl Prop="Value1" />

However, when I edit this in the property editor I get this xaml instead



  <ns:Value1 />



This doesn't work in my scenario because "Value1" in this case is a private inner class.  I have to have Cider serialize it as a string.  Is there any way to force it to do so?

I can provide an example if necessary.

A good example if just going through this walkthough of creating a type converter

What's new in XAML of .NET 4.0

With .NET 4.0 Microsoft will bring up a improved version of XAML. This arcitle shows you the language enhancements they made.
Easy Object References with {x:Reference}

Built-in Types

Generics in XAML with x:TypeArguments

Support for Arbitrary Dictionary Keys

Use of Non-Default Constructors with x:Arguments

Use of Static Factory Methods with x:FactoryMethod

Silverlight: Create Animations with XAML and Expression Blend


In this excerpt from his upcoming book, Laurence Moroney explains the basics of Silverlight animation and the animation tools available in Expression Blend.

Lawrence Moroney

MSDN Magazine August 2008

Service Station: Serialization in Windows Communication Foundation


Windows Communication Foundation supports several serialization mechanisms and provides a simple, interoperable foundation for future service-oriented applications. Here Aaron Skonnard explains it all.

Aaron Skonnard

MSDN Magazine August 2006

Class To Contract: Enrich Your XML Serialization With Schema Providers In The .NET Framework


The Microsoft .NET Framework 1.x provided minimal options for mapping classes to schemas and serializing objects to XML documents, making this sort of mapping quite a challenge. The .NET Framework 2.0 changes all this with Schema providers and the IXmlSerializable interface.

Keith Pijanowski

MSDN Magazine June 2006

Advanced Serialization: Format Your Way to Success with the .NET Framework Versions 1.1 and 2.0


While .NET offers adequate support for the simple serialization cases, issues arise when you're attempting to support delegates and subscribers, versioning, and class hierarchies. . In addition, the introduction of generics in The .NET Framework breaks new ground in the complexity of the serialization task and the power of serialization tools. This article discusses these issues and related pitfalls, suggests techniques and workarounds that address them, and recommends when and how to best use the new serialization abilities.

Juval Lowy

MSDN Magazine October 2004

Cutting Edge: Binary Serialization of DataSets


The ADO. NET DataSet object plays an essential role in most of today's distributed, multitiered applications. Instances of the DataSet class are used to move data across the tiers and to exchange data with external services.

Dino Esposito

MSDN Magazine October 2004

Cutting Edge: Binary Serialization of ADO.NET Objects


One of the key elements that makes ADO. NET superior to ADO is the level of integration with XML. In ADO, XML is just an I/O format. In addition, the ADO XML format is totally inflexible and doesn't allow any type of customization.

Dino Esposito

MSDN Magazine December 2002

.NET Column: Run-time Serialization, Part 3


This is the third part of my three-part series on serialization. In part one, I showed how to serialize and deserialize objects. I also showed how to define types that allow instances of themselves to be serialized.

Jeffrey Richter

MSDN Magazine September 2002

Is this an example of binary serialization


Hi , I have write this code for write error message in .txt file and this code is working fine.

void writeToLogFile(string logMessage)


        string strLogMessage = string.Empty;

        string strLogFile = System.Configuration.ConfigurationManager.AppSettings["logFilePath"].ToString();

        StreamWriter swLog;

        strLogMessage = string.Format("{0}: {1}", DateTime.Now, logMessage);

        if (!File.Exists(strLogFile))


            swLog = new StreamWriter(strLogFile);




            swLog = File.AppendText(strLogFile);






I want to know is this an example of binary serialization? 
If YES then please inform me from which line the serialization is done? 
If NO then please tell me an example of Binary Serialization ?

XML Serialization & List


 Hi all,


I'm working on the following code :


[System.Runtime.Serialization.DataContractAttribute(Name = "SalesOrder")]
    public partial class SalesOrder

        private List<OrderLine> orderLineField;


public SalesOrder()
            this.orderLineField = new List<OrderLine>();
            this.orderHeaderField = new OrderHeader();

        public List<OrderLine> OrderLine
                return this.orderLineFi

Help with creating dynamic XAML

Hi,  I need some help creating a complex XAML. I have a HotelRoom table with the below fields, ID Hotel HotelName Date RoomType Quantity  1    34    Hilton        3/5     Single      30  2    34    Hilton        3/6     Single      30  3    34    Hilton        3/7    Double     100  4    39    Express     3/5     King         10  5    39    Express     3/6    Double      20 Now I want the UI to display as a list of different records of Hotels with room details in them and I have created an object that has all the fields from the HotelRoom table,   HILTON               Single     Double    3/5        30          0    3/6 &n
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend