【发布时间】:2014-03-27 09:47:44
【问题描述】:
我需要 TabNavigation 来遍历整个 VisualTree。
我在视图中获得了一个自定义控件,我需要它的内部元素才能参与视图的 TabNavigation。
我需要在我的视图中使用 TabIndex,因为我需要标签流从上到下
自定义控件的模板:
<ControlTemplate>
<Grid>
<TextBox x:Name="first"/>
<TextBox />
<TextBox />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter TargetName="first" Property="FocusManager.FocusedElement" Value="{Binding ElementName=first}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
查看:
<Grid>
<Grid.ColumnDefentions>
<ColumnDefention />
<ColumnDefention />
</Grid.ColumnDefentions>
<TextBox Grid.Column="0" TabIndex="0" />
<local:MyControl Grid.Column="0" TabIndex="1" />
<TextBox Grid.Column="0" TabIndex="2" />
<TextBox Grid.Column="1" TabIndex="3" />
<TextBox Grid.Column="1" TabIndex="4" />
<TextBox Grid.Column="1" TabIndex="5" />
</Grid>
在导航到 TabIndex 0 时,然后是我控件中的第一个文本框,然后是第二个和第三个,TabIndex 2 IS NOT 导航到 ,就好像它丢失了选项卡索引。
如何将自定义控件模板内的导航合并到整个视图的选项卡流中?
【问题讨论】:
-
你使用过 IsTabStop 和 AcceptsTab 属性吗??