0

A am writing a WinRT application which utilises a Gridview to display some data. The Gridview has a SelectionMode of Extended so that as the user navigates the grid with the cursor keys the selected item moves with them (plus I have multi-select functionality)

The problem I'm experiencing is that if you navigate the grid using the cursor keys and have Ctrl pressed down, the selected item remains where is was and only the focus changes. My DataTemplate doesn't show the focused item so it's quite confusing to the user.

Is there anyway I can change this behaviour so that navigating the grid with Ctrl held down works in the same way as if it wasn't being held down?

Slade
  • 2,311
  • 3
  • 21
  • 25

1 Answers1

0

The solution was quite simple in the end. Just create a GotFocus handler like this one:

private void SdxGridView_GotFocus(object sender, RoutedEventArgs e)
{
  if (e.OriginalSource is GridViewItem && !((GridViewItem)e.OriginalSource).IsSelected)
  {
    SelectedItems.Clear();
    ((GridViewItem)e.OriginalSource).IsSelected = true;
  }
}
Slade
  • 2,311
  • 3
  • 21
  • 25