пятница, 12 ноября 2010 г.

XamlWriter.Save throws exception when trying to serialize empty ObservableCollection

I've encountered this exception, when tried to serialize empty ObservableCollection. Non-empty collection was serialized smoothly.

To fix it, create a wrapper class.

public class StringObservableCollection : ObservableCollection<string>
{
}

// ... 
var collection = new StringObservableCollection();
System.Windows.Markup.XamlWriter.Save(collection);

Комментариев нет:

Отправить комментарий