Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4254748
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:07:32+00:00 2026-05-21T05:07:32+00:00

I am having trouble write the xaml representation to allow to bind to my

  • 0

I am having trouble write the xaml representation to allow to bind to my background ViewModel for cascading menus

here’s the VM:

public class MenuNode
{
  public string Header {get;}
  public List<MenuNode> Items {get;}
}

the xaml i have is this:

<ContextMenu ItemsSource="{Binding Choices}" >
    <ContextMenu.Resources>
        <DataTemplate DataType="{x:Type vmi:MenuNode}">
            <MenuItem Header="{Binding Header}" ItemsSource="{Binding Items}"/>
        </DataTemplate> 
    </ContextMenu.Resources>
</ContextMenu>

When the menu pops up I get the first-level entries with an arrow(indicating that there should be a sub-menu) but when i hover over the menu it doesn’t show the sub-menu items.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T05:07:33+00:00Added an answer on May 21, 2026 at 5:07 am

    OK, here’s the issue:

    For some reason, the MenuItems that were generated by your DataTemplate are getting wrapped inside of another MenuItem (the result was nested MenuItems). The sub items were not being opened because the outer MenuItem had no children.

    The solution is to use a HierarchicalDataTemplate instead:

    <ContextMenu ItemsSource="{Binding Choices}" >
        <ContextMenu.Resources>
            <HierarchicalDataTemplate DataType="{x:Type vmi:MenuNode}" ItemsSource="{Binding Items}">
                <TextBlock Text="{Binding Header}"/>
            </HierarchicalDataTemplate> 
        </ContextMenu.Resources>
    </ContextMenu>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble outputting a data.frame using write.csv using UTF-16 character encoding. Background: I
I'm trying to write a style but am having trouble identifying a class of
I'm having trouble wrapping my head around how to write this query. A hypothetical
I am having trouble with XMLTextWriter.WriteStartElement throwing an exception: System.InvalidOperationException when trying to write
I'm having trouble getting a memory stream and a XML text writer class to
Hey all, I'm trying to write a sort function but am having trouble figuring
I am having trouble to write the binary algorithm in C/C++. My question is
I'm having trouble getting a bit to work properly in java6...I'm trying to write
I'm having trouble with my sqlite database. I'm trying to write an query that
I'm trying to write my own media player (like Foobar), and I'm having trouble

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.