Alessandro Del Sole's Blog

/* A programming space about Microsoft® .NET® */
posts - 159, comments - 0, trackbacks - 0

My Links


Your host

This is me! This space is about Microsoft® .NET® and Microsoft® Visual Basic development. Enjoy! :-)

These postings are provided 'AS IS' for entertainment purposes only with absolutely no warranty expressed or implied and confer no rights.

Microsoft MVP

My MVP Profile

I'm a VB!

Watch my interview in Seattle

My new book on VB 2015!

Pre-order VB 2015 Unleashed Pre-order my new book "Visual Basic 2015 Unleashed". Click for more info!

My new book on LightSwitch!

Visual Studio LightSwitch Unleashed My book "Visual Studio LightSwitch Unleashed" is available. Click the cover!

Your visits

Follow me on Twitter!

CodePlex download Download my open-source projects from CodePlex!

Article Categories


Post Categories

.NET Framework


Help Authoring

Microsoft & MSDN

Setup & Deployment

Visual Basic 2005/2008/2010

WPF: applying styles to Tooltips

Using styles in Windows Presentation Foundation, you can change also the layout of controls like Tooltip, those small text blocks which describe a particular object each time you pass over with the mouse pointer.

Try to type the following XAML code from within a new empty WPF project, inside the Window element:



        <Style x:Key="MyTooltip" TargetType="{x:Type ToolTip}">

          <Setter Property = "HorizontalOffset" Value="50"/>

          <Setter Property = "VerticalOffset" Value="50"/>

          <Setter Property = "Background" Value="Orange"/>

          <Setter Property = "Foreground" Value="Red"/>

          <Setter Property = "FontSize" Value="14"/>

          <Setter Property = "FontWeight" Value="Bold"/>

          <Setter Property = "FontFamily" Value="Courier New"/>




      <TextBox Margin="10,10,10,10" Height="20">

        Pass over with your Mouse


          <ToolTip Style="{StaticResource MyTooltip}">

            <TextBlock>This is the Tooltip</TextBlock>





The following is the result you'll see on your display:


As you can remember if you read my previous articles, styles must be declared inside a container's resources (in this case Grid.Resources). This time we have changed the control type which will receive the style by using a TargetType attribute.

You have just to specify a Style attribute when declaring your control to reference the style (in this case inside a ToolTip element).


Print | posted on martedì 14 aprile 2009 14:20 | Filed Under [ Windows Presentation Foundation ]


No comments posted yet.

Post Comment

Please add 3 and 1 and type the answer here:

Powered by:
Powered By Subtext Powered By ASP.NET