Welcome to our Microsoft Q&A platform!
You can set UriSource = "" for BitMapImage or not set Image.Source in the XAML, then set the image source in the cs.You can refer to the examples in the document for showing the picture.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
i am using a ink canvas and added a image to it and then serialize using XamlWriter.
Image img = new Image();
BitmapImage img = NImageHelper.GetBitmapImageFromString(ImageData, new Size(src.Width, src.Height));
img.Source = img;
string Xml = XamlWriter.Save(myCanvas);
this code works fine, Here is the xml generated
<Image Height="100" Width ="150">
<Image.Source>
<BitmapImage CacheOption="None" CreateOptions="IgnoreImageCache" BaseUri="{x:Null}"/>
</Image.Source>
</Image>
in this xml bitmapimage's StreamSource property is not serialized
When i try to parse it back it is throwing exception
System.Windows.Markup.XamlParseException: ''Initialization of 'System.Windows.Media.Imaging.BitmapImage' threw an exception.'
InvalidOperationException: Property 'UriSource' or property 'StreamSource' must be set.
It works fine if the bitmapimage's UriSource property is set and i am able to parse it back.
Please help me , how to serialize StreamSource property?
Thanks in advance.
Welcome to our Microsoft Q&A platform!
You can set UriSource = "" for BitMapImage or not set Image.Source in the XAML, then set the image source in the cs.You can refer to the examples in the document for showing the picture.