I have the following TextBox in one of my views:
<TextBox Name="SearchTerm" Style="{StaticResource SearchTermTextBoxStyle}"
Text="{Binding TemplatesViewModel.SearchTerm, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"
attachedProperties:Watermark.Watermark="Some watermark text"
KeyboardNavigation.TabIndex="5" />
Which has, as you can see, the following style applied:
<Style x:Key="SearchTermTextBoxStyle" TargetType="{x:Type TextBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid>
<TextBox Text="{Binding Text, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="{Binding (attachedProperties:Watermark.Watermark), Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" x:Name="DefaultTextPrompt"
Foreground="#888888" FontStyle="Italic" HorizontalAlignment="Left"
VerticalAlignment="Center" IsHitTestVisible="False" Visibility="Hidden"
Margin="5,-1,0,0" />
</Grid>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Text" Value="" />
<Condition Property="IsKeyboardFocusWithin" Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Visibility" TargetName="DefaultTextPrompt" Value="Visible" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
The problem is that when I obtain a focus on the SearchTerm TextBox, the cursor will not appear at all. First that came to my mind was simple conclusion: probably I get logical focus only, not keyboard focus. But that is not true. I can freely type in some text into that TextBox and I am still not getting cursor. When I am entering this TextBox using left mouse button, cursor appears and is blinking as expected.
What is wrong with my TextBox then?