#374 – Using a Tooltip to Display the Full Contents of a TextBox

It might often be the case that a TextBox control is not wide enough to display all of its text (the current value of its Text property).

The user could click in the TextBox control and move the cursor in order to see all of the text, but it would be handy to display the full contents in a tooltip.

You can set up a tooltip to display the full text of the Text property by setting the Tooltip property of the TextBox and using data binding to bind its value to the Text property.

        <TextBox Text="Now is the winter of our discontent Made glorious summer by this sun of York; And all the clouds that lour'd upon our house In the deep bosom of the ocean buried."
            ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}"
            Width="100" Margin="10"/>

Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

4 Responses to #374 – Using a Tooltip to Display the Full Contents of a TextBox

  1. steve f says:

    How could I arrange only to display the tooltip is there if not all the text is displayed in the text box?

  2. Keith says:

    This doesn’t seem to work if the TextBox Text itself is bound. Here’s my code:

  3. Ben says:

    Pass the same textbox binding element to tooltip

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: