I am developing my first app using MVVM and I am stuck with my command button.
In my view I have:
<Button x:Name="btSave" Command="{Binding AddContactCommand}" Content="Save" HorizontalAlignment="Left" Margin="183,186,0,0" VerticalAlignment="Top" Width="75"/>
In the code behind i have:
public partial class ContactView : Window
{
private ContactViewModel contactVM;
public ContactView()
{
InitializeComponent();
contactVM = new ContactViewModel();
this.DataContext = contactVM;
}
}
In the view model I have:
public ICommand AddContactCommand { get; private set; }
void AddContact()
{
ContactData ContactData = new ContactData();
bSaved = ContactData.SaveContact("Theresa","Theresa","Theresa","Theresa");
}
the AddContact()
in the view model never gets fired.
What I am doing wrong?