Alessandro Del Sole's Blog

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

My Links

News

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

Archives

Post Categories

.NET Framework

Blogroll

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:

    <Grid>

      <Grid.Resources>

        <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"/>

        </Style>

      </Grid.Resources>

 

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

        Pass over with your Mouse

        <TextBox.ToolTip>

          <ToolTip Style="{StaticResource MyTooltip}">

            <TextBlock>This is the Tooltip</TextBlock>

          </ToolTip>

        </TextBox.ToolTip>

      </TextBox>

    </Grid>

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).

Alessandro

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

Feedback

No comments posted yet.

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 7 and 8 and type the answer here:

Powered by:
Powered By Subtext Powered By ASP.NET