Search code examples
wpfxamltextboxcursor

Enable text hovering cursor when textbox is empty


I have some TextBox, when I hover my mouse over it, the cursor does not change:

Empty TextBox

However, when I enter some text, I do see a cursor when hovering:

Non-empty TextBox

I want the cursor to be visible in this text mode even when the textbox is empty.


Solution

  • The default behavior displays the I Beam when you mouse over a textbox, I'm unsure what is going on with your textbox, you may be overriding this behavior in a style.

    You could implement this trigger to get around it:

    <TextBox>
       <TextBox.Style>
          <Style TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
             <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                   <Setter Property="Cursor" Value="IBeam"/>
                </Trigger>
             </Style.Triggers>
           </Style>
         </TextBox.Style>
       </TextBox>