Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
焦点在列表和其他元素之间移动。WPF_Wpf_Focus - Fatal编程技术网

焦点在列表和其他元素之间移动。WPF

焦点在列表和其他元素之间移动。WPF,wpf,focus,Wpf,Focus,在我的窗口中有listview和其他元素。如何实现这种焦点行为:当我在最后一个列表上按下向下键时,项目焦点从另一个元素的listview移动,相应地,在第一个元素上按下向上键将焦点从列表中移开。 所以专注于按上下键可以从其他元素移动到列表中,通过抛出列表,然后离开列表 提前感谢。将附加属性设置为继续。包含ListBox的默认值 <ListBox KeyboardNavigation.DirectionalNavigation="Continue"/> 我的应用程序中有不同的情况。对

在我的窗口中有listview和其他元素。如何实现这种焦点行为:当我在最后一个列表上按下向下键时,项目焦点从另一个元素的listview移动,相应地,在第一个元素上按下向上键将焦点从列表中移开。 所以专注于按上下键可以从其他元素移动到列表中,通过抛出列表,然后离开列表

提前感谢。

将附加属性设置为继续。包含ListBox的默认值

<ListBox KeyboardNavigation.DirectionalNavigation="Continue"/>

我的应用程序中有不同的情况。对于所有控件,我都有自己的样式,但在tabcontrol的样式中,我设置了属性KeyboardNavigation.DirectionalNavigation=“Continue”。 1。此处应该可以选择listviewitems和tabitems。当我关注tabitem并按下(->)时,tabitem会发生变化。 2.此处应该可以选择listboxitems和按钮。 3.此处应该可以选择TabItem和TextBlock。 我可以用箭头而不是标签1

<TabControl  Name="tabControl1">
        <TabItem Header="PORT" Name="PORT">             
                <ListView  x:Name="ATList"                              
                          ItemsSource="{Binding Path=., NotifyOnTargetUpdated=true}"  
                          KeyboardNavigation.DirectionalNavigation="Continue"
                          KeyUp="ATList_KeyUp"  TargetUpdated="ATList_TargetUpdated">                        
                    <ListView.View>
                        <GridView >
                            <GridViewColumn> ........
                            </GridViewColumn>
                        </GridView>
                    </ListView.View>
                </ListView>               
        </TabItem>
        .......
</TabControl>    

........
.......
2.

<Grid> 
    <ListBox ItemsSource="{Binding    NotifyOnSourceUpdated=True,  NotifyOnTargetUpdated=True}"
             KeyboardNavigation.DirectionalNavigation="Continue"
             ClipToBounds="true" TargetUpdated="List_TargetUpdated" SourceUpdated="List_SourceUpdated">          
    </ListBox>
    <WrapPanel>  
        <Label  .../>
        <Label  .../>              
        <Button x:Name="NewBtn"                     
                IsEnabled="{Binding ElementName=UsedMemory, Path = Content, Converter={StaticResource RouteNewConverter}}" 
                Click="NewRouteBtn_Click"> New </Button>            
        <Button x:Name="DeleteBtn"  Click="DeleteBtn_Click"> Delete </Button>
    </WrapPanel>
</Grid>
 <TabControl Margin="2,5,2,1" Name="tabControl1" >
        <TabItem Header="AV" Name="AV">
            <Grid>
                <StackPanel x:Name="inf">
                            <TextBlock />
                                    ...
                            <TextBlock />                                            
                </StackPanel> 
            </Grid>
        </TabItem>
</TabControl>

新的
删除
3.

<Grid> 
    <ListBox ItemsSource="{Binding    NotifyOnSourceUpdated=True,  NotifyOnTargetUpdated=True}"
             KeyboardNavigation.DirectionalNavigation="Continue"
             ClipToBounds="true" TargetUpdated="List_TargetUpdated" SourceUpdated="List_SourceUpdated">          
    </ListBox>
    <WrapPanel>  
        <Label  .../>
        <Label  .../>              
        <Button x:Name="NewBtn"                     
                IsEnabled="{Binding ElementName=UsedMemory, Path = Content, Converter={StaticResource RouteNewConverter}}" 
                Click="NewRouteBtn_Click"> New </Button>            
        <Button x:Name="DeleteBtn"  Click="DeleteBtn_Click"> Delete </Button>
    </WrapPanel>
</Grid>
 <TabControl Margin="2,5,2,1" Name="tabControl1" >
        <TabItem Header="AV" Name="AV">
            <Grid>
                <StackPanel x:Name="inf">
                            <TextBlock />
                                    ...
                            <TextBlock />                                            
                </StackPanel> 
            </Grid>
        </TabItem>
</TabControl>

...

谢谢,但它只会让列表项循环。如何通过按上下键强制键盘焦点传递到其他元素?@Void:将其设置为循环可以做到这一点,但“继续”应该让它离开。是否将ListBox嵌套在另一个控件中,该控件可能已将其设置为循环?ListBox可能会让焦点离开,然后父控件会再次将其设置回ListBox的开头。如果您发布一些XAML,可能会有所帮助。