Bind a RadMenu to an XML File

7 posts, 0 answers
  1. Eduardo Lorenzo
    Eduardo Lorenzo avatar
    7 posts
    Member since:
    Mar 2010

    Posted 14 Apr 2010 Link to this post

    Hi everyone,

    Am not sure if this has been asked before. If so, please feel free to point to that direction.

    What I want to do is to bind a RadMenu to an XML file. The items are fairly static and that is why I chose an XML file. I also have the option to put in multiple xml files and do the binding run-time and point to the correct xml file as the situation calls for it.

    Thanks in advance!


  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 15 Apr 2010 Link to this post

    Hello Eduardo,

    To data-bind RadMenu to a XML file you should read it and create collection of objects, containing the needed properties for every XML element, then provide that collection as a ItemsSource on RadMenu.

    In my opinion it would be easier to use a XAML file instead of XML, like we do in the following example:
    http://demos.telerik.com/silverlight/#Menu/DataBinding

    Greetings,
    Valeri Hristov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. Eduardo Lorenzo
    Eduardo Lorenzo avatar
    7 posts
    Member since:
    Mar 2010

    Posted 15 Apr 2010 Link to this post

    Thank you for the Reply Valeri,

    I took a look at using a xaml file as the "datasource" but there is one line in the sample that I can't seem to understand:

        xmlns:menuModel="clr-namespace:Examples.Menu.Common;assembly=Examples.Menu

    I tried to declare/register it on my own project named sampleMenu but my intellisense fails.

    Thanks in advance!


  5. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 16 Apr 2010 Link to this post

    Hi Eduardo,

    This line declares a XML namespace for the objects that are inside the file. It works as any other similar declaration in your other XAML files. To fix it:
    xmlns:menuModel="clr-namespace:Examples.Menu.Common;assembly=Examples.Menu"
    would become:
    xmlns:menuModel="clr-namespace:<namespace>;assembly=<assembly>"
    where <namespace> should be the namespace where the MenuModel and MenuItem classes are declared; <assembly> should be the assembly which contains those classes.

    In our example the namespace is Examples.Menu.Common (see the MenuItem.cs for example) and the assembly is named Examples.Menu (this is set in the project properties).

    Kind regards,
    Valeri Hristov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. ss
    ss avatar
    37 posts
    Member since:
    Nov 2010

    Posted 30 Jun 2011 Link to this post

    i have follwed the below link

    http://demos.telerik.com/silverlight/#Menu/DataBinding

    in that i ahve taken the sample of code hwich is using for rad menu binding.

    but i am getting error.

    xmlns

    :menuModel="clr-namespace:Example.Menu.Common;assembly=Example.Menu"

    from this line i am getting the error as MenuItemColltecion is not found.

    i have checked the path/namespace is corect.
    could you please help me on this.

     

  7. ss
    ss avatar
    37 posts
    Member since:
    Nov 2010

    Posted 30 Jun 2011 Link to this post

     

    i have follwed the below link

    http://demos.telerik.com/silverlight/#Menu/DataBinding

    in that i ahve taken the sample of code hwich is using for rad menu binding.

    but i am getting error.

    xmlns

    :menuModel="clr-namespace:Example.Menu.Common;assembly=Example.Menu"

    from this line i am getting the error as MenuItemColltecion is not found.

    i have checked the path/namespace is corect.
    could you please help me on this.

  8. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 05 Jul 2011 Link to this post

    Hello,

    Please find attached an isolated project demonstrating the needed approach.

    Hope it helps.

    Regards,
    Yana
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top
DevCraft banner