Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

TreeViewItem doesn't give the focus to a TextBox inside its ControlTemplate

$
0
0
Hi

I am working on a custom tree view that displayes detail data in a hierachical list, like a ListView/GridView.
It uses TreeViewItems as its Item type, not a derived type.
The Control Template for the TreeViewItem type however is customized.
The column data is displayed by a GridViewRowPresenter / GridViewHeaderRowPresenter GridViewcolumns and their CellTemplates

All the time the data dislayed was readonly, the CellTemplates were TextBlocks -
most of the time and to cut a long story short.

Now I need to edit some piece of data/text and thought:
Use a TextBox rather than a TextBlock and you're done.

However the TextBox doesn't receive the focus.
I can't type into it, it doesn't display a caret, it's like there was some transparent gif above.

I used "Snoop" to check the viusal tree.
The TreeViewItem itself returns true for:
IsKeyBoardFocus, IsKeyBoardFocusWithin, IsFocused
but the first element in its control template, a Stackpanel, returns false for all of these 3 properties
the TextBox of course also negative for all three. And any element in between is also negative for the 3 focus props.

Now I played around with FocusManager.FocusedElement, FocusManager.IsFocused etc
but no luck. The TextBox remains uneditable.

Any Idea what's wrong
and how to find out why, where and how the focus gets lost?

Thx, Chris

Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>