ScrollViewer steals focus

Why in the next XAML, by clicking on the disabled button, make ScrollViewer steal focus from the TextBox? It is 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. But is this decision right?

+6
source share
1 answer

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

+2
source

Source: https://habr.com/ru/post/897446/


All Articles