2011-09-16 118 views
6

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

<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> 

设置IsFocusable = “假” 的ScrollViewer上的帮助。但它是正确的解决方法?

回答

2

是的,你可以做IsFocusable="False"IsHitTestable="False"

+0

但是是不是带走的可能性注重的ScrollViewer的滚动条按钮?这是一种解决方法还是剥离ScrollViewer可聚焦性的正确方法? –