This question is locked. New answers and comments are not allowed.
Hello,
I'm a big fan of Telerik, especially for how easy and clean are all the controls and their integration. I was very surprised to run into as much trouble as I did when trying to dynamically create a Silverlight RadMenu and add it to a StackPanel. We've been adding Buttons to the StackPanel without a single problem, so I thought what can be difficult about adding a RadMenu? For some reason I can't get it to happen! I can't find any helpful examples, so maybe you could help me out. This is what I'm trying to do:
All the Buttons show up ok, but not the RadMenu! The most I can get to happen is to get the space allocated on the StackPanel, i.e. all the buttons are shifted to the right, as if something invisible is there.
Please help!
I'm a big fan of Telerik, especially for how easy and clean are all the controls and their integration. I was very surprised to run into as much trouble as I did when trying to dynamically create a Silverlight RadMenu and add it to a StackPanel. We've been adding Buttons to the StackPanel without a single problem, so I thought what can be difficult about adding a RadMenu? For some reason I can't get it to happen! I can't find any helpful examples, so maybe you could help me out. This is what I'm trying to do:
StackPanel spButton = new StackPanel();
TextBlock txtButtonText = new TextBlock();
Image img = new Image();
Double BtnWidth = 125;
Double BtnHeight = 25;
StackPanel ganttMainToolBar = null;
ganttMainToolBar = new StackPanel();
ganttMainToolBar.Name = "ganttMainToolBar";
ganttMainToolBar.Orientation = Orientation.Horizontal;
ganttMainToolBar.VerticalAlignment = VerticalAlignment.Center;
ganttMainToolBar.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
ganttMainToolBar.Width = _ganttWidth - 5;
ganttMainToolBar.Height = BtnHeight;
ganttMainToolBar.SetValue(Grid.RowProperty, 0);
ganttMainToolBar.SetValue(Grid.ColumnProperty, 0);
ganttMainToolBar.Margin = new Thickness(5, 5, 0, 5);
ganttMainToolBar.Tag = "100";
RadMenu radMenu = new RadMenu();
radMenu.Name = "radMenu";
radMenu.Tag = "111";
radMenu.Height = BtnHeight;
radMenu.Width = 200;
StyleManager.SetTheme(radMenu, new VistaTheme());
RadMenuItem topLevelItem = new RadMenuItem();
topLevelItem.Name = "file";
topLevelItem.Header = "File";
topLevelItem.Tag = "1111";
topLevelItem.Height = BtnHeight;
topLevelItem.Width = 100;
StyleManager.SetTheme(topLevelItem, new VistaTheme());
radMenu.Items.Add(topLevelItem);
ganttMainToolBar.Children.Add(radMenu);
#region new item
Button btnNewButton = new Button();
btnNewButton.Name = "AddNewItemButton";
spButton = new StackPanel();
spButton.Orientation = Orientation.Horizontal;
spButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
spButton.VerticalAlignment = System.Windows.VerticalAlignment.Center;
img = new Image();
img.Source = new BitmapImage(new Uri("add2.png", UriKind.Relative));
img.Width = 16; img.Height = 16;
img.Margin = new Thickness(5, 0, 5, 0);
spButton.Children.Add(img);
txtButtonText = new TextBlock();
txtButtonText.Text = "Add New Item";
txtButtonText.Margin = new Thickness(5, 0, 5, 0);
spButton.Children.Add(txtButtonText);
btnNewButton.Content = spButton;
btnNewButton.Margin = new Thickness(0, 0, 0, 0);
btnNewButton.Tag = "104";
btnNewButton.Click += new RoutedEventHandler(GanttTable_AddTasks);
btnNewButton.IsEnabled = DisableBtnForSnapShot();
btnNewButton.Width = BtnWidth;
ganttMainToolBar.Children.Add(btnNewButton);
ToolTipService.SetToolTip(btnNewButton, "Add New Item");
#endregion
LayoutRoot.Children.Add(ganttMainToolBar);
All the Buttons show up ok, but not the RadMenu! The most I can get to happen is to get the space allocated on the StackPanel, i.e. all the buttons are shifted to the right, as if something invisible is there.
Please help!