Vassili

Vassili

  • NA
  • 1
  • 0

How to skip serialization of individual child controls?

Oct 5 2009 10:33 AM
Hello!

The problem i'm faced with is to omit serialisation of specifc child controls of my UIElement-based WPF control.

More precisely, I have MyWindowsFormsHost derived from WindowsFormsHost. An instance of this is populated with a child control (say, different types of data grids, charts, whatever), linked with a IBindingList-based collection

   public class MyWinFormsDataGridView : WindowsFormsHost, IMyUIElement
{
DataGridView _gridView;
public MyWinFormsDataGridView()
{
this._gridView = new DataGridView();
this._gridView.DataSource = ...;
this.Child = this._gridView;
}
}
When I save a grid with and instance of this class in XAML (simply by XamlWrite.Save(grid) ), I get tones of data from data binding, and corresponding perfomance drop:

<MyGrid Name="grid1">      
<MyWinFormsDataGridView ...>
<swf:DataGridView ...>
...
<swf:DataGridView.DataSource>
<MyBindingList><tones of data i dont need to save...></MyBindingList>
</swf:DataGridView.DataSource>
</swf:DataGridView>
</MyWinFormsDataGridView>
</MyGrid>
I would like to skip saving

<swf:DataGridView ...>
...
<swf:DataGridView.DataSource>
<MyBindingList><tones of data i dont need to save...></MyBindingList>
</swf:DataGridView.DataSource>
</swf:DataGridView>
and have in the output only the following:

<MyGrid Name="grid1">      
<MyWinFormsDataGridView>...</MyWinFormsDataGridView>
</MyGrid>
Can anybody indicate a relatively simple solution for this?