This question is locked. New answers and comments are not allowed.
Hi,
Ihave a class that inherits from RadGridView,
for each instacne of this grid we always add a button in the header of the first column, when clicking on this button it shold open a context menu, I have locked at your example onhow to do it but it does not work for me, here is my code:
what am I doing worng? when I click on the button the menu is not opened
Thanks
Ron
Ihave a class that inherits from RadGridView,
for each instacne of this grid we always add a button in the header of the first column, when clicking on this button it shold open a context menu, I have locked at your example onhow to do it but it does not work for me, here is my code:
this is the code that I am adding to the grid header, it is being added in OnApplyTemplate:
GridViewColumn column = this.Columns[0]; string headerText = column.Header.ToString(); StackPanel headerPanel = new StackPanel(); headerPanel.Orientation = Orientation.Horizontal; Button b = new Button(); b.Content = "Menu"; b.Click += new RoutedEventHandler(b_Click); headerPanel.Children.Add(b); TextBlock t = new TextBlock(); t.Text = headerText; headerPanel.Children.Add(t); column.Header = headerPanel;
this is the event hanlder of the added buttonvoid b_Click(object sender, RoutedEventArgs e) { RadContextMenu contextMenu = new RadContextMenu(); contextMenu.ItemClick += new Telerik.Windows.RadRoutedEventHandler(contextMenu_ItemClick); // set menu Theme StyleManager.SetTheme(contextMenu, StyleManager.GetTheme(this)); RadMenuItem item = new RadMenuItem() { Header = "Export CSV" }; //item.Click += new Telerik.Windows.RadRoutedEventHandler(item_Click); contextMenu.Items.Add(item); RadMenuItem item1 = new RadMenuItem() { Header = "Print" }; //item1.Click += new Telerik.Windows.RadRoutedEventHandler(item1_Click); contextMenu.Items.Add(item1); //contextMenu.AddHandler(RadMenuItem.ClickEvent, new RoutedEventHandler(OnMenuItemClick));\\ RadContextMenu.SetContextMenu((sender as Button), contextMenu); // attach menu // RadContextMenu.SetContextMenu(cell, contextMenu); }
what am I doing worng? when I click on the button the menu is not opened
Thanks
Ron
