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 8943453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:46:26+00:00 2026-06-15T11:46:26+00:00

Trying to get a list of submenu items to bind to an ObservableCollection. I

  • 0

Trying to get a list of submenu items to bind to an ObservableCollection.

I can get the binding to work on the top level menu. I can also get the items to show in the submenu if I add them in code, which I’d like to avoid.

MainWindow.xaml:

    <ContextMenu x:Key="tbMenu" >

        <-- Top level menu item -->
        <MenuItem Name="menuLaunchJob" Header="Launch a Job" >
            <-- Display a list of the available jobs in a submenu -->
            <MenuItem.ItemTemplate>    <-- This doesn't work -->
                <DataTemplate>
                    <MenuItem ItemsSource="{Binding}" Header="{Binding jobName}" />
                </DataTemplate>
            </MenuItem.ItemTemplate>
        </MenuItem>

        <-- Top level menu item -->
        <MenuItem Name="menuEditJobs" Header="Edit Jobs" >
    </ContextMenu>

    <!-- Globally declared notify icon -->
    <tb:TaskbarIcon x:Key="StatusIcon" 
                    MenuActivation="LeftOrRightClick" 
                    ContextMenu="{StaticResource tbMenu}" />

MainWindow.xaml.cs:

public partial class MainWindow : Window
{
    private static TaskbarIcon mTaskBar = null;

    public MainWindow()
    {
        JobsClass jc = new JobsClass();

        Environment.CurrentDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
        InitializeComponent();
        mTaskBar = (TaskbarIcon)this.FindResource("StatusIcon");

        // Job sub-menu list is always the 1st item in the main menu
        MenuItem launchJob = (MenuItem)mTaskBar.ContextMenu.Items[0];
        launchJob.DataContext = jc.mJobs;
    }

    public class JobsClass
    {
        private static JobConfig mJobConfig = JobConfig.Instance;
        public ObservableCollection<JobConfig.JobData> mJobs = new ObservableCollection<JobConfig.JobData>();

        public JobsClass()
        {
            mJobConfig.ReadJobs(); 
            foreach (JobConfig.JobData job in mJobConfig.GetJobs())
            {
                mJobs.Add(job);
            }
        }
    }
}
  • 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-06-15T11:46:28+00:00Added an answer on June 15, 2026 at 11:46 am

    Try this:

        <-- Top level menu item -->
        <MenuItem Name="menuLaunchJob" Header="Launch a Job" ItemsSource="{Binding}" DisplayMemberPath="jobName">
    

    (Assuming your {Binding} is set to your ObservableCollection)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a list of all top level desktop windows in an
Trying to get these list headings to line up correctly, but I can't figure
Trying to get menu header with active color when submenu is opened CSS: #main-nav,
Im trying to get a list of line items to a webpage using JSON,
I am trying to get list of numbers from: numbers= 1,2 to: '1','2' I
Trying to get a list of all substrings currently I have a function but
I am trying to get a list of tmux sockets that are currently being
I am trying to get the list of connected components in a graph with
I am trying to get a list of Files in a Folder from Google
I'm trying to get a list in JavaScript (not using jQuery) of all the

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.