2011-09-16 30 views
6

次のXAMLで無効なボタンをクリックすると、ScrollViewerがTextBoxからフォーカスを奪うのはなぜですか?そうですか?回避策は何ですか? IsFocusable ScrollViewerの助けに= "false" に設定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> 

。しかし、それは正しい回避策ですか?

答えて

2

はい、あなたはIsFocusable="False"またはIsHitTestable="False"

+0

を行うことができます。しかし、それは、ScrollViewerのスクロールバーのボタンに集中する可能性を奪うされていませんか?回避策ですか、それともScrollViewerのフォーカスを取り除くのが正しい方法ですか? –

関連する問題