Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
XmlSerializer deserializer = new XmlSerializer(typeof(question_list));
                
                TextReader reader = new StreamReader("x1.xml");
                object obj = deserializer.Deserialize(reader);
                question_list XmlData = (question_list)obj;
                reader.Close();
                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
Edited 10-Nov-12 2:04am
v2
Comments
OriginalGriff at 10-Nov-12 7:53am
   
And?
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 at 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 at 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
good
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.BeginInit();
    bitmapImage.StreamSource = memory; <------
    bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
    bitmapImage.EndInit();
}
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 540
1 OriginalGriff 300
2 CPallini 290
3 ChauhanAjay 124
4 George Jonsson 120
0 OriginalGriff 6,474
1 Sergey Alexandrovich Kryukov 6,190
2 CPallini 5,180
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2014
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