private void ButFavorite_Click(object sender, RoutedEventArgs e) { Peripheral p = (Peripheral)((FrameworkElement)sender).DataContext; _viewModel.Favorite(p.IsFavorite ? null : p); }