小编Vic*_*yov的帖子

ScrollViewer窃取焦点

为什么在下一个XAML中单击禁用按钮会导致ScrollViewer从TextBox中窃取焦点?这样对吗?解决方法是什么?

<Window
x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
FocusManager.FocusedElement="{Binding ElementName=TextBox}">
<ScrollViewer>
    <StackPanel>
        <TextBox x:Name="TextBox"/>
        <Button IsEnabled="False" Content="Disabled Button"/>
    </StackPanel>
</ScrollViewer>
Run Code Online (Sandbox Code Playgroud)

在ScrollViewer上设置IsFocusable ="False"有帮助.但这是正确的解决方法吗?

wpf focus scrollviewer

6
推荐指数
1
解决办法
3203
查看次数

标签 统计

focus ×1

scrollviewer ×1

wpf ×1