delegateCommand is not executing on menuitem.

Topics: Prism v4 - Silverlight 4
Jul 22, 2012 at 10:52 PM

Hi friends out there.

In My Prism MVVM applicatin i have bind property with commar of menuitem  but it is not working.Below is my code of view and viewmodel.

This is my view code:

        <toolkit:MenuItem  Header="Home"  Width="Auto" Height="24"  VerticalAlignment="Top" Command="{Binding Path=__showcommand}" />


This is corresponding viewmodel code:

 public class test1: INotifyPropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;
        public ICommand _showcommand{set;get;}
        public FamilyTreeMenuBarViewModel()
            this._showcommand = new DelegateCommand(showmessage);

        public void showmessage()

but when i am clicking on this menu .This command execute function is not working.So if there is something wrong in code please let me know and make it clear why we need to do that.

Thanks in advance

Jul 23, 2012 at 6:20 PM


After checking the code snippets you posted, I found a typo that could be the cause behind this problem. Although it's difficult to see, in the biding of the view showcommand has two underscores, while in the view model it only has one underscore. Therefore, the binding is not working because the name in the menu item's binding is different than the one in the view model.


Damian Cherubini

Jul 24, 2012 at 3:20 AM

Thanks for reply.

I figure out  the problem which i had in my code.


Pankaj Goswami