Context menu Dynamicaly

4 posts, 0 answers
  1. ruty
    ruty avatar
    42 posts
    Member since:
    Mar 2009

    Posted 26 Apr 2009 Link to this post

    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.

     

  2. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 27 Apr 2009 Link to this post

    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.
  3. DevCraft banner
  4. Denis Vuyka
    Denis Vuyka avatar
    39 posts
    Member since:
    Oct 2009

    Posted 19 Mar 2010 Link to this post

    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()
  5. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 19 Mar 2010 Link to this post

    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.
Back to Top