private void UserControl_MouseUp(object sender, MouseButtonEventArgs e) { var o = sender as FrameworkElement; var variation = o.DataContext as Variation; if (variation == null) { return; } var parentItem = UIHelper.FindVisualParent <ListViewItem>(this); if (parentItem == null) { throw new Exception("Can't handle click on VariationThumbnail outside of ListItem"); } var parentList = UIHelper.FindVisualParent <ListView>(this); bool isSelectedFromFavoritesList = parentList.Name == "XFavoritesGrid"; if (isSelectedFromFavoritesList) { variation.SelectFavorite(); } else { variation.SelectVariation(); } parentItem.IsSelected = variation.IsSelected; }