wpf - Why does ItemsControl show a focus rectangle when its parent is focused? -
itemprop = "text">
ItemsControl of WPF will display a focus shape when it appears that its focus is on and the user presses the press tab or Alt.
But I recently had an item controlwall displaying a focus rectangle, even if it was not a focus - one of his parents did it. Item control was inside a user control, which was inside other user controls, which had done focus something like this:
& lt ;! - UserControl1.xaml; This is the control that has been taken care of - & gt; & Lt; UserControl x: Class = "UserControl1" Focusable = "True" ... & gt; & Lt; UserControl2 / & gt; & Lt; / UserControl & gt; & Lt ;! - UserControl2.xaml - & gt; & Lt; UserControl x: class = "UserControl2" & gt; & Lt; Item control ... /> & Lt; / UserControl & gt; Or, visually showing nesting:
+ --------------------- ----------------------------- + | UserControl1 (Focus is) | | | | + ----------------------------------------------- + | | | UserControl2 | | | | | | | | + ------------------------------------------- + | | | | | ItemsControl (Focus Shows Rectangle) | | | I took a while (and A) to find out how the focus rectangle was coming from, because I had never expected a control on which to show focus rectangle There was no focus for. / P>
I'm still learning my way around WPF, and obviously I do not know enough yet, or it does not confuse me, I have two questions to understand:
- < Li> Why the itemcontrol displays focus rectangle when it does not really focus, but does one of its original controls? What is the reason for this facility? (I'm sure there is one - maybe what to do with templates or visual papers? - I have no deep understanding of WPF mechanics and philosophy yet.)
- < / Em> How does this work? To decide whether to use the item control, the focus rectangle should be displayed, what is the mechanism?
Are you sure that ItemsControl is not focused? If this is to draw a focus rect, then it should be just because the high level of control in the visual tree is centered does not mean that none of its children is centered. To understand, make sure that you have learned the difference between WPF "Logical Focus" and "Keyboard Focus". One is on MSDN.
Comments
Post a Comment