1

I have a ListView control in XAML that has items styled by a template.

The template contains a TextBox

When I tab between controls on my keyboard, I get a selection box around the entire template, and on the next tab the focus goes to the first TextBox.

How can I be notified when the focus changes on the ListView?

[update 1] This is a start: How to add a Blend Behavior in a Style Setter

First I need to hook into the GotFocus/LostFocus events. The best way to do this is with a behavior, so following the details above, I created a boolean attached property IsScrollIntoViewEnabled.

I then set that value in a style for the ListViewItemContainerStyle.

So phase I is that I know when an item gains and loses focus. What I still don't know is how to get back from the ListViewItem to the ListView itself.

Community
  • 1
  • 1
Anthony Wieser
  • 4,351
  • 1
  • 23
  • 25

1 Answers1

0

I solved the final piece of the puzzle, getting the ListView from the ListViewItem by walking through VisualTreeHelper.GetParent(x) until I found an object of the correct type.

Anthony Wieser
  • 4,351
  • 1
  • 23
  • 25