Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScrollViewer steals focus

Why in the next XAML clicking on disabled button cause ScrollViewer to steal focus from TextBox? Is it right? What is the workaround?

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

Setting IsFocusable="False" on ScrollViewer helps. But is it right workaround?

like image 579
urdait Avatar asked Sep 16 '11 05:09

urdait


1 Answers

Yes you can do IsFocusable="False" or IsHitTestable="False"

like image 140
Zahid Sattar Avatar answered Oct 23 '22 13:10

Zahid Sattar