This is a migrated thread and some comments may be shown as answers.

Bind a RadMenu to an XML File

6 Answers 114 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Eduardo Lorenzo
Top achievements
Rank 1
Eduardo Lorenzo asked on 14 Apr 2010, 09:07 AM
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!


6 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 15 Apr 2010, 04:25 PM
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.
0
Eduardo Lorenzo
Top achievements
Rank 1
answered on 16 Apr 2010, 02:50 AM
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!


0
Valeri Hristov
Telerik team
answered on 16 Apr 2010, 04:30 PM
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.
0
ss
Top achievements
Rank 1
answered on 30 Jun 2011, 11:39 AM

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.

 

0
ss
Top achievements
Rank 1
answered on 30 Jun 2011, 11:41 AM
 

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.

0
Yana
Telerik team
answered on 05 Jul 2011, 03:04 PM
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!

Tags
Menu
Asked by
Eduardo Lorenzo
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Eduardo Lorenzo
Top achievements
Rank 1
ss
Top achievements
Rank 1
Yana
Telerik team
Share this question
or