Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2320
ParentXamMenuItem
posted

Does this property work?  I'm using Infragistics 10.1 (10.1.20101.2022).

I have simple file menu that I'm trying to recursively walk the file menu items and I wanted to be able to tell if it was the uppermost Menu Item.  ParentXamMenuItem appears to be null even at the second level in the file menu.

Is there additional work required to get this property to work?

Parents
No Data
Reply
  • 6475
    Verified Answer
    posted

    Hi,

    Since you can place any type of object in menu's Items collection, the menu generates UI containers (XamWebMenuItems) for these objects (like any ItemsContainer does).

    So this property returns the parent container element that holds the container of the specified item. These containers are created on demand, which means that if the submenu for this item was never expanded, UI container is not generated for it. So in this case you're trying to get the parent for a container that's still not constructed and attached to the visual tree. This is why you're getting null values.

    The same thing will happen if you try to get the XamWebMenuItem container for a particular submenu item using ItemContainerGenerator's methods (e.g., ContainerFromIndex()) if this submenu was never expanded.

    So you have two options:

    1. Make sure the submenu that contains the desired item was previosly expanded (e.g., by toggling the IsSubmenuOpen property of the parent)

    2. If you're not adding some custom objects in menu's Items collection, but you only use XamWebMenuItems, you could get the Parent instead of ParentXamMenuItem. This should work without expanding the submenus. In this case, you should check if the parent is a XamWebMenuItem or a XamWebMenu (for root level items).

     

     

    Hope this helps,

Children
No Data