I have some (homemade) controls in a wrappanel in a scrollviewer and I want my controls to get focus when I click on them or Tab through them. But the wrappanel grabs the focus and hands it to Children.
<ScrollViewer IsTabStop="False" >
<!-- children, filled in from code. IsTabStop="True" -->
The scrollviewer did the same thing but its
IsTabStop="False" made it behave. However, the WrapPanel does not have a
IsTabStop property. So how can I make it stop grabbing focus from its children?
I tried to set focus 'manually', using
Focus(), from a mouse click eventhandler in my controls. The control gets focus but the wrappanel grabs it right away and it ends up at Children, even though I attempt to stop the mouseclick event from bubbling up (
e.Handled = true).
Best How To :
Somehow its working fine for me. sharing the code snippet of what I tried.
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Image Name="img" Height="100" Width="100"/>
<TextBox Name="tb3" Text="text2" KeyDown="tb3_KeyDown" Width="200"/>
<toolkit:WrapPanel Orientation="Vertical" Name="wp">
Adding textboxes from code behind
TextBox tb2 = new TextBox();
TextBox tb = new TextBox();
tb.Text = "some text";
tb.Width = 200;
tb2.Text = "some text";
tb2.Width = 200;
Changing focus from one textbox inside grid to textbox inside WrapPanel
private void tb3_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
if(e.Key == System.Windows.Input.Key.Enter)