views:

602

answers:

1

I've got a ListBox, within it I have a custom DataTemplate that builds a button. Each button represents a selection the user can perform.

When the button is clicked, is there anyway I can retrieve the original data record for that bound item? In standard C#, I can create a button and use CommandArgument to pass an ID to an event. Is there something similar in Silverlight?

Thanks

+1  A: 
private void RemoveMember_Click(object sender, RoutedEventArgs e)
{
    var employee = ((Button)sender).DataContext as Employee;
    if(employee == null)
     return;
    _employeeList.Items.Remove(employee);
}
Anton Kutepov

related questions