private void RemoveGame_OnClick(object sender, RoutedEventArgs e) { var item = sender as DependencyObject; while (!(item is ListViewItem)) { item = VisualTreeHelper.GetParent(item); } item.SetValue(ListViewItem.IsSelectedProperty, true); _mainPageVM.RemoveGame(); }