Add Image to ToolTip : ToolTip « Windows Presentation Foundation « C# / C Sharp






Add Image to ToolTip

Add Image to ToolTip
     



<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="WPF" Height="160" Width="300">
    <Window.Resources>
        <Style TargetType="{x:Type ToolTip}">
            <Setter Property="Width" Value="100"/>
            <Setter Property="Height" Value="100"/>
            <Setter Property="OverridesDefaultStyle" Value="True"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate 
                        TargetType="{x:Type ToolTip}">
                        <Border Name="Border"
                            BorderBrush="DarkGray"
                            BorderThickness="1"
                            Width="{TemplateBinding Width}"
                            Height="{TemplateBinding Height}"
                            CornerRadius="4">
                            <StackPanel Orientation="Horizontal">
                                <Image Margin="4,4,0,4" Source="c:\image.gif"/>
                                <ContentPresenter
                                  Margin="4" 
                                  HorizontalAlignment="Left"
                                  VerticalAlignment="Top" />
                                </StackPanel>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </Window.Resources>

    <Grid>
            <TextBlock Foreground="DarkGray" 
                       VerticalAlignment="Center" 
                       HorizontalAlignment="Center"
                       ToolTip="This is a custom tooltip"
                       Text="Mouse Over for tooltip"/>
    </Grid>
    
</Window>

   
    
    
    
    
  








Related examples in the same category

1.ToolTip for BorderToolTip for Border
2.Using ToolTip for TextBox with TextBox.ToolTip and ToolTip tagUsing ToolTip for TextBox with TextBox.ToolTip and ToolTip tag
3.Add ToolTip text to a TextBoxAdd ToolTip text to a TextBox
4.ToolTipService.InitialShowDelayToolTipService.InitialShowDelay
5.ToolTip with ImageToolTip with Image
6.ToolTipService.Placement="Bottom"ToolTipService.Placement=
7.ToolTip with List itemsToolTip with List items
8.A Tool Tip on a Disabled ControlA Tool Tip on a Disabled Control
9.Disabled Button with ToolTipServiceDisabled Button with ToolTipService
10.Control the Display Duration and Position of a Tool TipControl the Display Duration and Position of a Tool Tip
11.Set ToolTip Placement, ShowDuration, VerticalOffsetSet ToolTip Placement, ShowDuration, VerticalOffset
12.Set ToolTipService.Placement="Center"Set ToolTipService.Placement=
13.Set drop shadow for a ToolTipSet drop shadow for a ToolTip
14.Set border for ToolTip by using ControlTemplateSet border for ToolTip by using ControlTemplate
15.Complex ToolTipComplex ToolTip
16.ToolTip With BindingToolTip With Binding