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

Context menu Dynamicaly

3 Answers 119 Views
Menu
This is a migrated thread and some comments may be shown as answers.
ruty
Top achievements
Rank 1
ruty asked on 26 Apr 2009, 06:19 AM
Hi,
I want to full my context menu whith items in run time.

RadContextMenu

 

d = new RadContextMenu();

 

 

RadMenuItem y = new RadMenuItem();
d.items.add(y);
y is child of d. 

I want to add items to y in click event.

The code in click event:

 

 

RadMenuItem h1 = new RadMenuItem();

 

h1.Header =

"h1";
y.items.add(h1);

but I get Error:" AG_E_UNKNOWN_ERROR".
 
The details:
   at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
   at MS.Internal.XcpImports.MethodEx(DependencyObject obj, String name)
   at MS.Internal.XcpImports.Control_ApplyTemplate(Control control)
   at System.Windows.Controls.Control.ApplyTemplate()
   at Telerik.Windows.Controls.RadMenuItem.ChangeTemplate(MenuItemRole role)
   at Telerik.Windows.Controls.RadMenuItem.UpdateRole()
   at Telerik.Windows.Controls.RadMenuItem.OnItemsChanged(NotifyCollectionChangedEventArgs e)
   at System.Windows.Controls.ItemsControl.RaiseOnItemsChanged(NotifyCollectionChangedEventArgs e)
   at System.Windows.Controls.ItemCollection.NotifyItemsControl(NotifyCollectionChangedEventArgs e)
   at System.Windows.Controls.ItemCollection.AddInternal(Object value)
   at System.Windows.PresentationFrameworkCollection`1.Add(T value)
   at W6.Web.UI.Actions.Class1.Invoke(IList selectedObjectsInFocus)

Can you help me??
Thanks.

 

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 27 Apr 2009, 07:38 AM
Hello ruty,

I've attached an example demonstrating how to add RadMenuItem dynamically.

Let us know if you need more help.

Kind regards,
Hristo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Denis Vuyka
Top achievements
Rank 1
answered on 19 Mar 2010, 01:05 PM
I have a serious problem removing dynamically created context menu from within the menu item click (2010_1_0309_DEV). The context menu in my scenario contains a "Delete" option for the element. Before the element is deleted I call "RadContextMenu.SetContextMenu(MYELEMENT, null)" and only after that remove my element from the visual tree.

However in the release mentioned above I immediately receive "Nullreference Exception" (this didn't happen in previous versions of the suite):

Code: 4004
Category: ManagedRuntimeError
Message: System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.Windows.Controls.PopupWrapper.CloseRootPopup()
0
Hristo
Telerik team
answered on 19 Mar 2010, 03:19 PM
Hi Denis Vuyka,

Thank you for reporting this. It is fixed and the fix will be included in today's Latest Internal Build (it will be uploaded shortly).
Your telerik points have been updated.

Sincerely yours,
Hristo
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.
Tags
Menu
Asked by
ruty
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Denis Vuyka
Top achievements
Rank 1
Share this question
or