Creating Dynamic Silverlight Controls by parsing an xml file

Last post 04-06-2008 9:18 AM by johannes.hiemer. 1 replies.

Sort Posts:

  • Creating Dynamic Silverlight Controls by parsing an xml file

    03-31-2008, 10:51 AM
    • Loading...
    • jainsunil12
    • Joined on 03-28-2008, 2:39 PM
    • Posts 6

    Dear all,

     I need to create dynamic silverlight controls after parsing an xml file. This logic might also involve using of Datasets and other data objects.

    But datasets are not supported in Silverlight.

    I also need to embed this silverlight page in a certain portion of my asp.net page.

    So, Can anyone let me know, how do i achieve this?

    Any help would be appreciated.

    Thanks in advance.

    Regards,

    Sunny.

  • Re: Creating Dynamic Silverlight Controls by parsing an xml file

    04-06-2008, 9:18 AM

    Hi,

    take a look here: http://dotnet.johanneshiemer.de/?p=9. Reading the Xml-File with LINQ is now the easy part. I give you an example of what I did:

     

    1     public XDocument LoadXmlDocument(string documentName)
    2            {
    3                XDocument document = XDocument.Load(documentName);
    4                if (document != null)
    5                    return document;
    6                else
    7                    return null;
    8            }
    9    
    10           public List GetXmlMenu()
    11           {
    12               XDocument document = LoadXmlDocument("menu.xml");            
    13   
    14               var menues = from menu in document.Descendants("menu")
    15                       select new XmlMenu
    16                       {
    17                           title = menu.Element("title").Value,
    18                           image = menu.Element("image").Value,
    19                           description = menu.Element("description").Value
    20                       };
    21   
    22               if (menues.Count() != 0)
    23                   return menues.ToList();
    24               else
    25                   return null;
    26           }
    
     

     

    (If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

    Best Regards,
    Johannes

    http://www.irisindividuell.de
    http://www.itecon.de
    http://www.johanneshiemer.de
Page 1 of 1 (2 items)