In a WPF window, I'm trying to put the cursor by default on one of the textboxes. After reading some questions and answers, I tried the following:
xaml:
<StackPanel Grid.Row="1"
<StackPanel.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding UserShouldEditValueNow}" Value="true">
<Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=FID}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
<TextBox Name ="FID" Text="{Binding FixID, UpdateSourceTrigger=PropertyChanged}"
FocusManager.FocusedElement="{Binding RelativeSource={RelativeSource Self}}"/>
</StackPanel>
cs: (Viewmodel)
this.UserShouldEditValueNow = true;
I expected to see a blinking cursor on the textbox FID when opening the window. However, there's no cursor at all on this textbox. Debugging showed me that I'm going through the cs code, setting the value to true. any ideas why?