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

To create menu dynamically along with icons

2 Answers 85 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Anupam
Top achievements
Rank 1
Anupam asked on 27 Jul 2011, 10:46 AM
I am able to create the menu dynamically for radmenu from data base,but i am unable to populate the icons for the same .
Kindly Suggest the solution for the same..
I have tried MenuItem.Icon property but its not either helping me out.

The code for populating menu are:
IN XAML:
<telerik:RadMenu  x:Name="GEMSMenu" Style="{StaticResource Mainmenus}" FontWeight="Bold"  Cursor="Hand" Margin="30,0"  Background="{x:Null}" Foreground="White" Grid.Row="1"  VerticalAlignment="Bottom" FontSize="12" FontFamily="Arial"  BorderBrush="{x:Null}"  >
   </telerik:RadMenu>
IN XAML.CS

  private void LoadMenu(GetMenuProviderDetailCompletedEventArgs MenuProvider)
        {
            var parentList = (from Parmenu in MenuProvider.Result where Parmenu.ParentId.Equals(string.Empty)  select Parmenu).Distinct();

            foreach (var parent in  parentList)
            {
                 RadMenuItem MenuItem = new RadMenuItem();
                 MenuItem.Header = parent.MenuName;
                GEMSMenu.Items.Add(MenuItem);
                var ChildList = (from childmenu in MenuProvider.Result where childmenu.ParentId.Equals(parent.MenuId)  select childmenu).Distinct();

                foreach (var child in ChildList)
                {
                    RadMenuItem ChildItem = new RadMenuItem();
                   
                    ChildItem.Header = child.MenuName;
                    MenuItem.Items.Add(ChildItem);
                    var SubChildList = (from Subchildmenu in MenuProvider.Result where Subchildmenu.ParentId.Equals(child.MenuId)   select Subchildmenu).Distinct();

                    foreach (var Subchild in SubChildList)
                    {
                        RadMenuItem SubChildItem = new RadMenuItem();
                        SubChildItem.Header = Subchild.MenuName;
                        ChildItem.Items.Add(SubChildItem);

                    }

                }
            }
        }

 

2 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 29 Jul 2011, 12:05 PM
Hello Anupam,

I cannot see how do you set the Icon property, but here is a help article that should be useful:
http://www.telerik.com/help/silverlight/radmenu-features-icons.html

Kind regards,
Valeri Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Anupam
Top achievements
Rank 1
answered on 29 Jul 2011, 12:13 PM
Actually I have to create menus dynamically along with menu icons using MVVM pattern....Is it possible to do so?
Tags
Menu
Asked by
Anupam
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Anupam
Top achievements
Rank 1
Share this question
or