Click here to Skip to main content
13,145,464 members (81,802 online)
Rate this:
Please Sign up or sign in to vote.
See more:
XmlSerializer deserializer = new XmlSerializer(typeof(question_list));
                TextReader reader = new StreamReader("x1.xml");
                object obj = deserializer.Deserialize(reader);
                question_list XmlData = (question_list)obj;
                t1.Text = XmlData.q_list[0].mytext;
                img1.Source = XmlData.q_list[0].img;// my issue
              button1.Content=  XmlData.q_list[0].option1;
              button2.Content = XmlData.q_list[0].option2;
              button3.Content = XmlData.q_list[0].option2;
Posted 10-Nov-12 1:48am
Updated 10-Nov-12 2:04am
OriginalGriff 10-Nov-12 7:53am
Your problem is what? Is there an error message? Does it do anything? If so what?
Use the "Improve question" widget to edit your question and provide better information.
OriginalGriff 10-Nov-12 8:15am
No, that doesn't help - remember that all we can see is what you tell us - we can't see your screen, or access your HDD.
What you have told us so far is "I have a problem with this line" but not what the problem is. We can't test it ourselves, because we don't know what your data is - we don't have access to the file. We don't know what you expect the code to do, and we can't tell what it does do! So we can't tell if you get an error message, or a corrupt image, or your computer bursts into flames!

Help us to help you - give us the information to look at the problem!
Nelek 10-Nov-12 8:18am
Please have a look:
what have you tried?[^]
How to ask a question?[^]

The better you describe your problem, the easier will be for the CPians to help you

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I guess you want to load it in a WPF control. Source property points to a ImageSource, usually an URL, but I think you want to load the actual image data (encoded Base64 in xml). You need to use ImageSource - precisely BitmapImage. See below how you can load it, just set the memory to whatever you loaded (code is from stackoveflow, but I don't put the link here because the answers might be confusing)

using(MemoryStream memory = new MemoryStream())
    bitmap.Save(memory, ImageFormat.Png);
    memory.Position = 0;
    BitmapImage bitmapImage = new BitmapImage();
    bitmapImage.StreamSource = memory; <------
    bitmapImage.CacheOption = BitmapCacheOption.OnLoad;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100