Here is what I want : I want to focus on that textbox when the user clicks on the label next to the text box , also I have to use this event "PreviewMouseLeftButtonUp" for label
What have I tried :
<Window.Resources>
<Storyboard x:Key="OnLabelCLick">
<BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="FocusManager.FocusedElement" Storyboard.TargetName="text22">
<DiscreteBooleanKeyFrame KeyTime="0" Value="True"/>
</BooleanAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger RoutedEvent="UIElement.PreviewMouseLeftButtonUp" SourceName="LBL1">
<BeginStoryboard Storyboard="{StaticResource OnLabelCLick}"/>
</EventTrigger>
</Window.Triggers>
<Grid>
<Label Content="Label" x:Name="LBL1" HorizontalAlignment="Left" Margin="210,200,0,0" VerticalAlignment="Top" Height="95" Width="370" Cursor="Hand" Background="#FF1B1B1C" Foreground="White"/>
<TextBox x:Name="text22" HorizontalAlignment="Left" Height="70" Margin="210,85,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="360" RenderTransformOrigin="0.5,0.5" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
</TextBox>
</Grid>
But I see this Error
when I click on the label :
System.InvalidOperationException: 'Cannot resolve all property references in the property path 'FocusManager.FocusedElement'. Verify that applicable objects support the properties.'
I want to do all thing only in XAML
How can I do that ?
Please help
Reference : Set focus on textbox in WPF