Q:

context menu item only displays correctly on the second right click

I have a treeview where its items are gathered from a couple of xml files.  Then, depending on which treeview item is selected, a custom context menu is displayed.  This all works well, except I believe I am hitting the issue as described in this MSDN Article.
I must be missing something with the suggested workaround that the article describes but I am stuck on what exactly that is.
When I right click a treeview item (in this case, I am focusing on the root treeview item that is called "Clients"), the context menu appears on the first right mouse click as expected and the text for the menu item is "This will be replaced."  If I right-click a second time, the context menu that is displayed is the desired "Add New Group".  From here all works in terms of launching a window to enter a new group, etc. 
I am also not 100% sure how to check if a contextmenu is null as suggested so perhaps this is what I am missing.  Any direction or comments on what I am missing for the workaround would be greatly appreciated.
The XAML for the treeview:
 <TreeView x:Name="TreeViewDisplay"
           Grid.Row="0"
           Grid.Column="0"
           DockPanel.Dock="Left"
           Margin="5 5 0 5"
           MinWidth="180"
           SelectedItemChanged="TreeViewDisplay_SelectedItemChanged"
           ContextMenuOpening="treeviewContextMenu_ContextMenuOpening">
        <TreeView.ContextMenu>
             <ContextMenu x:Name="treeviewContextMenu"
                          Style="{StaticResource baseControlStyle}" >
                <MenuItem Header="This will be replaced." />
             </ContextMenu>
         </TreeView.ContextMenu>
     </TreeView>

The code behind:
        private void treeviewContextMenu_ContextMenuOpening(object sender, ContextMenuEventArgs e)
    {
        FrameworkElement fe = e.Source as FrameworkElement;

        TreeViewItem selectedTreeViewItem = e.Source as TreeViewItem;
        string selectedTreeViewItemHeader = selectedTreeViewItem.Header.ToString();

        if (selectedTreeViewItemHeader == "Clients")
        {
            fe.ContextMenu = TreeViewContextMenuIfTopLevelSelected();
        }
        else
        {
            MessageBox.Show("no menu to display");
        }
    }

    ContextMenu TreeViewContextMenuIfTopLevelSelected()
    {
        // This is the menu that will show if the top level treeview item is selected
        ContextMenu topLevelMenu = new ContextMenu();

        // Define menu items
        MenuItem addNewGroup = new MenuItem();
        addNewGroup.Header = "Add New Group";
        addNewGroup.Click += addNewGroup_Click;

        // add menuitems defined above to the menu
        topLevelMenu.Items.Add(addNewGroup);
        return topLevelMenu;
    }

    void addNewGroup_Click(object sender, RoutedEventArgs e)
    {
        AddNewGroup newGroupAdd = new AddNewGroup();

        newGroupAdd.Closed += new EventHandler(RefreshTreeView);
        newGroupAdd.Show();
    }

    private void RefreshTreeView(object sender, EventArgs e)
    {
        TreeViewDisplay.Items.Clear();
        GetTreeViewGroupList();
    }

A:

I was able to figure this out.  There might be a more eloquent way to do this, but it worked for my purposes.
I changed the ContextMenuOpening event to the following:
    private void treeviewContextMenu_ContextMenuOpening(object sender, ContextMenuEventArgs e)
    {
        FrameworkElement fe = e.Source as FrameworkElement;

        TreeViewItem selectedTreeViewItem = e.Source as TreeViewItem;
        string selectedTreeViewItemHeader = selectedTreeViewItem.Header.ToString();

        if (fe.ContextMenu != null)
        {
            if (selectedTreeViewItemHeader == "Clients")
            {
                fe.ContextMenu = TreeViewContextMenuIfTopLevelSelected();
            }
            else
            {
                MessageBox.Show("no menu to display");
            }
        }
        else
        {
            e.Handled = true;

            if (selectedTreeViewItemHeader == "Clients")
            {
                fe.ContextMenu = TreeViewContextMenuIfTopLevelSelected();
                fe.ContextMenu.IsOpen = true;
            }
            else
            {
                fe.ContextMenu = TreeViewContextMenu();
                fe.ContextMenu.IsOpen = true;
            }
        }
    }

