#376 – Getting Text to Wrap in a Tooltip

When you specify the value of a tooltip by setting the Tooltip property for a control, a popup window for the tooltip is created and the window contains a single label.  By default, this label does not wrap, but displays in a single long line.

If you want the text in a tooltip to wrap, you can specify an explicit Tooltip control in XAML and set it up to contain a TextBlock.  The TextBlock has a TextWrapping property that lets you wrap the text.

        <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."
            Width="100" Margin="10">
                <ToolTip DataContext="{Binding Path=PlacementTarget, RelativeSource={x:Static RelativeSource.Self}}">
                    <TextBlock Text="{Binding Text}" TextWrapping="Wrap" Width="200"/>