Currently with a scrollviewer, clicking the scroll bar contained in it to pan the content around it will not focus the viewer (or anything for that matter). I wish to have it so when you scroll by dragging the scroll, or even clicking the scrollbar will focus the parent (scroll viewer).
I achieved this somewhat by attaching a ScrollChanged handler on the scrollviewer and calling sender.focus(). Unforutnally ScrollChanged is called on initialising the scrollviewer and so on loading the
I also tried attaching event setters with still no luck.
Ideally I would like it on some sort of style or something which allows me to apply it to all scrollviewers across the entire application.
Edit: Just for futher clarification, if I use this xaml and click on the scroll bar it will not turn the background blue (gotfocus event). When I click inside the scroll viewer or the button it will.
<Window x:Class="GotFocusProblem.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">
<Grid>
<Grid Margin="20" x:Name="grid">
<Grid.Background>
<SolidColorBrush x:Name="backgrnd" Color="Transparent"/>
</Grid.Background>
<ScrollViewer Margin="10" Height="100" Background="#FFEEEEEE">
<Button Content="Button" Name="button1" Height="300" Width="75" />
</ScrollViewer>
<Grid.Triggers>
<EventTrigger RoutedEvent="Grid.GotFocus">
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Storyboard.TargetName="backgrnd"
Storyboard.TargetProperty="Color"
To="Cyan"
BeginTime="0:0:0"
Duration="0:0:0" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
</Grid>
</Grid>
</Window>