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

  • Home
  • SEARCH
  • 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 6016103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:56:05+00:00 2026-05-23T02:56:05+00:00

I am trying to create a menu bar for my application. I have created

  • 0

I am trying to create a menu bar for my application. I have created a collection in xaml that I will contain menu items that my menu will bind to.

In xaml I have created an array that I use as my static resource for binding.

<coll:ArrayList x:Key="MenuOptionsList">
        <model:DashboardMenuBarItem 
               Icon="the location of an image in my images folder" 
               DisplayName="The test that will appear under my button"  
               CommandName="someCommandInMyViewModel"/>
</coll:ArrayList>

I am using a listbox with a data template to show these items as follows.

<ListBox x:Name="lstNavigateTo" MinWidth="400" DockPanel.Dock="Top"
             ItemsSource="{Binding Source={StaticResource MenuOptionsList}}" 
             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
             Style="{StaticResource horizontalListTemplate}">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Margin="5">
                    <Button Height="60" Width="60"
                            Command="{Binding Mode=OneWay, Path=CommandName}">
                        <Button.Content>
                            <Image Source="{Binding Path=Icon}" Grid.Row="0" />
                        </Button.Content>
                    </Button>
                    <TextBlock Text="{Binding Path=DisplayName}" 
                               Width="100" TextAlignment="Center" Grid.Row="1" />
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
</ListBox>

My problem is that I am using the MVVM design pattern and cannot get the command bindings to work on the button click. Previously I would have managed the button click like this.

Command="{Binding someCommandInMyViewModel}"

That would work fine but when I try to bind a command to a property of an item in my collection the command will not fire.

Does anyone know how I can achieve this.

  • 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-23T02:56:06+00:00Added an answer on May 23, 2026 at 2:56 am

    The CommandName property in your collection is of type String, whereas the Command property on Button is of type ICommand. In what way are you expecting WPF to resolve an ICommand from a String? You’ll need to help it: either create a converter and use it in your binding, or change your CommandName property so that it contains an actual ICommand rather than a String.

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

Sidebar

Related Questions

I am trying to create a simple GUI. I have a menu bar that
I'm trying to create a css menu bar that has all grey text with
I'm trying to create a horizontal menu with a thick border bar that shows
I have been trying to create a menu panel with jQuery that can be
I am trying to create a menu bar with the following items: File, Database,
I am trying to create a menu bar which will consist of a series
I'm trying to create a menu that will stick at the bottom of the
I'm trying to create a two-level horizontal navigation menu (or menubar) that displays the
I am trying to create a menu that slides up from the bottom. It
I'm trying to make a simple menu bar only application on xcode 4. Everything

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.