My class uses the image as Property ( public Image myImage). When this class is serialized ( XamlWriter), it works fine, reading it returns an exception:
'Match constructor not found by type' System.Drawing.Bitmap. You can use the Arguments or FactoryMethod directives to create this type. 'Line number "5" and line position "8".
Obviously, for Bitmap with ColorPalette, the constructor is missing as an argument:
<sd:Bitmap>
<sd:Bitmap.Palette>
<sdi:ColorPalette />
</sd:Bitmap.Palette>
</sd:Bitmap>
I understand that I can specify a factory method that creates a bitmap in some way. I also found some articles on directives for this, for example http://www.wpftutorial.net/XAML2009.html
However, I am not an expert in Xamland do not understand how and where to define / declare a method according to my attribute. Unfortunately, I also do not find an example for this.
I expect something like
[FactoryMethod("XYZ")]
public Image myImage ....
but actually found nothing. Any idea / example you know?
source
share