Alex Rivera | Logout

Can you bind a whole object to a CommandParameter in XAML?

Asked 2010-10-04T16:30:44.737
10

I have a linkbutton inside a listbox that receives a list of objects. I'm using the ListBox.ItemTemplate and DataTemplate to lay out the listbox items. Can I bind the entire object that is currently binding to the command parameter of the linkbutton? I've tried using

CommandParameter={Binding Data}

and

CommandParameter={Binding DataItem}

but I always get the error in output that 'Data' or 'DataItem' is not a property on said object. Is this even possible?

Edit
Report

1 Answer

21

Try this

CommandParameter = {Binding}

It will bind to the current object which used to generate the item

answered 2010-10-04T16:35:00.640

Your Answer