Can i serialize and deserialize a DataRowView from a WPF ComboBox?
<p>I'm filling the itemssource of a WPF combobox in code-behind with a datatable containing the columns "Listkey" and "Listvalue" like that:</p>

<pre><code>SetElementProperty(element, "ItemsSource", (new ListtablesRead()).ReadListtable(changeTextProperties.SelectedListTable).DefaultView);
SetElementProperty(element, "DisplayMemberPath", "Listvalue");
SetElementProperty(element, "SelectedValuePath", "Listkey");
</code></pre>

<p>SetElementProperty is a method which checks by reflection, if the frameworkelement (in that case the combobox) has the given property and sets it.</p>

<p>Then i want to serialize the control with XmlWriter.
So i wrote a converter class for the type DataRowView:</p>

<pre><code>using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Markup;

namespace WPFDesignerConverterLibrary
{
    public class DataRowViewConverter : ExpressionConverter
    {
        /// &lt;summary&gt;
        /// Finds out if the converter can convert an expression-object to the given destinationtype.
        /// &lt;/summary&gt;
        /// &lt;param name="context"&gt;An ITypeDescriptorContext-interface which provides a context for formatting.&lt;/param&gt;
        /// &lt;param name="destinationType"&gt;A type-class which represents the target-type of the conversion.&lt;/param&gt;
        /// &lt;returns&gt;Returns an object of type bool. True = the destinationtype can be converted.&lt;/returns&gt;
        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
            if (destinationType == typeof(MarkupExtension))
                return true;

            return false;
        }

        /// &lt;summary&gt;
        /// Converts the expression to the given destinationtype.
        /// &lt;/summary&gt;
        /// &lt;param name="context"&gt;An ITypeDescriptorContext-interface which provides a context for formatting.&lt;/param&gt;
        /// &lt;param name="culture"&gt;The System.Globalization.CultureInfo which is actually used as culture.&lt;/param&gt;
        /// &lt;param name="value"&gt;The object to convert.&lt;/param&gt;
        /// &lt;param name="destinationType"&gt;A type-class which represents the target-type of the conversion.&lt;/param&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value,
            Type destinationType)
        {
            if (destinationType == typeof(MarkupExtension))
            {
                DataRowView datarowview = value as DataRowView;
                if (datarowview == null)
                    throw new Exception();
                return datarowview.Row;
            }

            return base.ConvertTo(context, culture, value, destinationType);
        }
    }
}
</code></pre>

<p>This converter works and produces the following lines in the serialized XML:</p>

<pre><code>  &lt;sd:DataRow RowError=""&gt;
    &lt;sd:DataRow.ItemArray&gt;
      &lt;x:Array Type="s:Object" xml:space="preserve"&gt;&lt;s:String&gt;01&lt;/s:String&gt;&lt;s:String&gt;Ersttest                      &lt;/s:String&gt;&lt;/x:Array&gt;
    &lt;/sd:DataRow.ItemArray&gt;
  &lt;/sd:DataRow&gt;
  &lt;sd:DataRow RowError=""&gt;
    &lt;sd:DataRow.ItemArray&gt;
      &lt;x:Array Type="s:Object" xml:space="preserve"&gt;&lt;s:String&gt;02&lt;/s:String&gt;&lt;s:String&gt;Wiederholungstest             &lt;/s:String&gt;&lt;/x:Array&gt;
    &lt;/sd:DataRow.ItemArray&gt;
  &lt;/sd:DataRow&gt;
  &lt;sd:DataRow RowError=""&gt;
    &lt;sd:DataRow.ItemArray&gt;
      &lt;x:Array Type="s:Object" xml:space="preserve"&gt;&lt;s:String&gt;03&lt;/s:String&gt;&lt;s:String&gt;Konstanzprüfung               &lt;/s:String&gt;&lt;/x:Array&gt;
    &lt;/sd:DataRow.ItemArray&gt;
  &lt;/sd:DataRow&gt;
</code></pre>

<p>But when i try to reload the serialized XML i get an error message, which says, that no standard constructor for the type DataRow was found.
What's going wrong?
And further: To set the itemssource of the combobox with a datatable's defaultview is the simplest way to do this, but can it be that i have to go another way?</p>

<p>InnerException: 
       =-2146233069 HResult
       Message=For the type "System. Data. DataRow" no standard constructor was found. The type can be provided with the argument or the FactoryMethod directive.
       Source=System. Xaml
       StackTrace:
            at system. Xaml. Pattern. XamlTypeInvoker. DefaultCtorXamlActivator. EnsureConstructorDelegate (XamlTypeInvoker type)
            at system. Xaml. Pattern. XamlTypeInvoker. CreateInstance (Object [] of argument)
            at MS.Internal. Xaml. Run time. ClrObjectRuntime. CreateInstanceWithCtor (XamlType xamlType, Object [] args)
            at MS.Internal. Xaml. Run time. ClrObjectRuntime. CreateInstance (XamlType xamlType, Object [] args)</p>