【发布时间】:2016-02-18 20:30:54
【问题描述】:
哎呀!完全忘记了我拥有的应用程序范围的样式,这是按钮上的边距。我已经修改了代码和 gif 以反映这一点。
我有以下 XAML 标记:
<Window x:Name="SampleMainWindow1" x:Class="SampleApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="300">
<DockPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" Grid.Row="1">
<StackPanel Orientation="Horizontal">
<Button Margin="40,40,40,40" Width="Auto">Button 1</Button>
<Button Margin="40,40,40,40" Width="Auto">Button 2</Button>
<Button Margin="40,40,40,40" Width="Auto">Button 3</Button>
<Button Margin="40,40,40,40" Width="Auto">Button 4</Button>
</StackPanel>
</ScrollViewer>
</Grid>
</DockPanel>
但是,当一个按钮接收到焦点,例如Button 1,并且我按下右键时,我会立即关注Button 2,但是正如你所看到的,我必须在Button 3 之前再按几次右获得焦点,Button 4 也是如此。
如何使按键立即聚焦在下一个按钮上,并且该按钮会滚动到视图中?
【问题讨论】:
-
Win7 操作系统会出现这种情况吗?我在Win8.1试了一下,效果如你所愿。
-
天哪!...对不起,我似乎错过了一个关键点!是的,这发生在 Windows 7 上。抱歉,我没有提到操作系统,因为我认为这种行为将更多地依赖于 GUI 框架而不是操作系统。
标签: wpf button windows-7 scrollviewer arrow-keys