2011-09-16 122 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可聚焦性的正確方法? –