WPF Button Command not firing, what am I missing?

I feel bad posting this because I see a ton of similar posts, but after going through them all I can't quite diagnose my issue still. What I have is a WPF app designed with the MVVM pattern and using a RelayCommand() implementation for commands.

In my user control's XAML I set the data context here :

    <viewModel:SidePanelViewModel />

Then further down in the XAML I have this snippet where I assign a button's command

<TextBlock FontWeight="Bold" Margin="0,0,0,10">Service List</TextBlock>
<ListBox MaxHeight="100"
        ItemsSource="{Binding ServiceList}"
        SelectedItem="{Binding ServiceToRemove}">
<Button HorizontalAlignment="Left" Width="60" Margin="0,10"
        Command="{Binding RemoveServiceCommand}">Remove</Button>

I am binding the button to the Command RemoveApplicationCommand which I define in the SidePanelViewModel here :

public ICommand RemoveServiceCommand
    get { return new RelayCommand(RemoveService, CanRemoveService); }

private void RemoveService()

private bool CanRemoveService()
    return true;

The problem

If I debug, the getter for RemoveServiceCommand will be reached when the button starts up, but when I click the button the code doesn't reach it. I had a very similar implementation (or so I think) working before, so this is really puzzling me. How can I get the command to fire on click?


Command="{Binding RemoveApplicationCommand}"

Did you mean RemoveServiceCommand?

Need Your Help

How to check if column value is null before inserting data from text box

c# asp.net ado.net

I am trying to insert data from text box to sql database, but I want to check if the row is empty then insert new value else update the row with the values with sqlcommands in if else condition.

PHP MySQL: Update a Join table?

php mysql sql relationship

I'm a bit confused as to how to best update a join table.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.