This project has moved and is read-only. For the latest updates, please go here.

Pass value by CommandParameter

May 18, 2010 at 5:12 AM

Plz help me, how about pass value by CommandParameter property.

May 18, 2010 at 10:09 AM

I don't know how to do this because I have never found the need to. I would consider passing the value seperately using a binding. If you go down the CommandParameter route you are in danger of introducing logic into the view which should be in the view model.

May 20, 2010 at 8:55 PM

The DelegateCommand implementation supports the CommandParameter property:


<Button Command="{Binding SaveCommand}"  
        CommandParameter="{Binding SelectedItem,Element=listBox1}" />


saveCommand = new DelegateCommand(Save);
private void Save(object parameter)
    Person selectedPerson = parameter as Person;    
... }
May 24, 2010 at 2:51 AM

Thanks Alot...

That works fine.