I’ve been trying for a couple extra hours and been unable to solve it, or to find info regarding this particular problem, so I might as well drop the bomb to you, @curtisw
Let’s see, I’ve generated a custom class, a dynamic control that depending on its input it assigns the control to one of three options. This is probably the source of the problem, but the compiler is allowing to serialize this without any trouble, so here is the custom class:
(tried using an enum for the constructor but i wanted to keep it simple, so i rolled back to int).
namespace EtoXamlSample
{
[Serializable]
public class CustomDynamicControl : DynamicControl
{
public enum ControlOutputs
{
BUTTON,
NUMERICSTEPPER,
TEXTBOX
}
public CustomDynamicControl(System.Int32 output)
{
switch(output)
{
case 0://ControlOutputs.BUTTON:
Control = new Button
{
Text = "DynamicButton"
};
break;
case 1://ControlOutputs.NUMERICSTEPPER:
Control = new NumericStepper
{
DecimalPlaces = 3,
Increment = 0.1,
Value = 1,
MinValue = 0,
MaxValue = 10
};
break;
case 2://ControlOutputs.TEXTBOX:
Control = new TextBox
{
Text = "DynamicTextBox"
};
break;
default:
Control = new TextBox
{
Text = "DefaultDynamic"
};
break;
}
}
}
}
This, i call from the next panel:
<?xml version="1.0" encoding="UTF-8"?>
<Panel
xmlns="http://schema.picoe.ca/eto.forms"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:EtoXamlSample;assembly=EtoXamlSample"
xmlns:rhino="clr-namespace:Rhino;assembly=RhinoCommon"
>
<TableLayout x:Name ="SamplePanelLayout">
<TabControl>
<TabPage Text = "Tab 3">
<local:CustomDynamicControl>
<x:Argument>
<x:Int32>
2
</x:Int32>
</x:Argument>
</local:CustomDynamicControl>
</DynamicLayout>
</TabPage>
</TabControl>
</TableLayout>
</Panel>
I would understand it just got crazy over me trying to serialize something such as Dynamic Control with controls defined in runtime, but instead it yields:
Type ‘Portable.Xaml.XamlObjectWriterException’ in Assembly ‘portable.Xaml, Version = 0.14.0.0, Culture=neutral, PublicKeyToken=blabla…’ is not marked as serializable.
Im assuming the error lies within my code, and it’s causing the XamlObjectWriter to go nuts.
If that is so, how would you go around doing a dynamic control such as this?