Bug Report Q145126
Visible to All Users

The GetNavBarGroup method returns null for NavBarGroup descendants

created 16 years ago

Hello,
I have a problemm with GetNavBarGroup of the NavBarControl.
In xaml I have something like this:
<dxn:NavBarControl Name="navBar" HorizontalAlignment="Right" DockPanel.Dock="Right">
            <dxn:NavBarControl.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Add group" Name="miAddGroup" Click="miAddGroup_Click"></MenuItem>
                </ContextMenu>
            </dxn:NavBarControl.ContextMenu>
            <dxn:NavBarControl.View>
                <dxn:SideBarView>
                    <!–dxn:SideBarView.ContextMenu>
                    </dxn:SideBarView.ContextMenu–>
                </dxn:SideBarView>
            </dxn:NavBarControl.View>
            <dxn:NavBarControl.Groups>
                <dxn:NavBarGroup>
                </dxn:NavBarGroup>
            </dxn:NavBarControl.Groups>
        </dxn:NavBarControl>
For getting group, where menu was opened I use code like this "_actionNavBarGroup = navBar.View.GetNavBarGroup(e);" in navBar.ContextMenuOpening += new ContextMenuEventHandler(View_ContextMenuOpening);
Firstly, as you see in navbar in xaml a added empty grour, because <dxn:NavBarGroup></dxn:NavBarGroup>, otherwise context menu doesnt open. Also you can see that I have commented SideBarView.ContextMenu in sidebarview, because I tryed to do this and following in 2 ways of defining menu. (Sorry for my English -)
Secondly. After running a programm I call context menu and call miAddGroup_Click, in actionNavBarGroup I have that empty group. Its ok. But than I clear navBar.Groups and dynamicly add new group:
public class VMCNavBarGroup : NavBarGroup
    {
        public List<Filter> Filters { get; set; }
        public QueryConstructorResultTypes FilterType { get; set; }
    }

VMCNavBarGroup nbg = new VMCNavBarGroup();
nbg.Header = qc.GroupName;
foreach (…)
                                {
                                    NavBarItem nbi = new NavBarItem();
                                    nbi.Content = p.NameLoc;
                                    nbg.Items.Add(nbi);
                                }
navBar.Groups.Add(nbg);
After I see on the form my new group an its items. But than I call context menu:
 - clicking on Group header: navBar.View.GetNavBarGroup(e) is null
 - clicking on any item: navBar.View.GetNavBarGroup(e) is null and navBar.View.GetNavBarItem(e) != null
Then I tryed same operetions on menu defined in SideBarView.ContextMenu, result the same.
As I can understand navBar.View.GetNavBarGroup(e) != null, only when groups are defined in xaml, not added dynamicly. But most likely I do something wrong.

Comments (2)
AM AM
Aleksandr Merkulov 16 years ago

    Hi,
    suddenly I localized the problemm.
    I wrote that I use NavBarGroup inherited class VMCNavBarGroup , and add it to the groups collection, and navBar.View.GetNavBarGroup(e) retirns null. I tryed to use real NavBarGroup class
    NavBarGroup nbg = new NavBarGroup();
    nbg.Header = qc.GroupName;
    foreach (…)
                                    {
                                        NavBarItem nbi = new NavBarItem();
                                        nbi.Content = p.NameLoc;
                                        nbg.Items.Add(nbi);
                                    }
    navBar.Groups.Add(nbg);
    and everything works, I thind that maybe that problemm appear only if I use inherited class of NavBarGroup.

    DevExpress Support Team 16 years ago

      Hi Aleksandr,
      Thank you for the update.
      Yes, that seems to be the cause of the problem. We've discussed this problem with our developers, and have decided that it looks like an issue in the current product version. So, I've converted this question to a bug report, and we'll do our best to fix it as soon as we can.
      Thanks,
      Vito

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.