0

View: <Button Command="{Binding GetChangeLogCommand}"

ViewModel: GetChangeLogCommand = new DelegateCommand(GetChangeLog);

Method:

public ICommand GetChangeLogCommand { get; set; }
private async void GetChangeLog(bool isLatest)
{
    // code goes here . . .
}

I'm going to useGetChangeLogCommand multiple time and pass boolean parameter is it possible with MVVM sorry I'm new with this.

  • you have to use ViewModel binding for that i guess – Ehsan Sajjad Jun 28 '16 at 01:49
  • and also see this :http://stackoverflow.com/questions/32064308/how-to-pass-command-parameter-to-method-in-viewmodel-in-wpf – Ehsan Sajjad Jun 28 '16 at 01:50
  • At your `Button` you can also bind a property called `CommandParameter`. This value will be passed to your command-handler – Tomtom Jun 28 '16 at 06:09
  • Possible duplicate of [How to pass data between the View and the ViewModel](http://stackoverflow.com/questions/20036466/how-to-pass-data-between-the-view-and-the-viewmodel) – FoldFence Jun 28 '16 at 06:41

1 Answers1

0

If you are that particular to pass the button element to viewmodel You can use below code :

 CommandParameter="{Binding ElementName=YourButtonName}"

You could even pass the entire window, user control, or a particular list or list item to the view model

 CommandParameter="{Binding ElementName=YourWindow}"     
 CommandParameter="{Binding ElementName=Control}"
ViVi
  • 4,339
  • 8
  • 29
  • 52