Click here to Skip to main content
16,008,954 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've created a Resource dictionary for tool-tip styling, so that i can use in the application.
I've added the Resource dictionary in the same project.

it is as mentioned below

C#
<Style x:Key="{x:Type ToolTip}"  TargetType="{x:Type ToolTip}">
	<Setter Property="OverridesDefaultStyle" Value="true"/>
	<Setter Property="VerticalOffset" Value="-2" />
	<Setter Property="HorizontalOffset" Value="20" />
	<Setter Property="Placement" Value="Bottom" />
	<Setter Property="Opacity" Value="1" />
	<Setter Property="FontFamily" Value="Arial"/>
	<Setter Property="Template">
		<Setter.Value>
			<ControlTemplate TargetType="{x:Type ToolTip}">
				<Grid Name="Border" removed="Transparent" Width="{TemplateBinding Width}" Height="Auto"  MinHeight="30">
					<Rectangle RadiusX="3" RadiusY="3"  Stroke="#FF1E86C1" Opacity="1" Margin="2,2,2,2">
						<Rectangle.Fill>
							<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
								<GradientStop Color="#FFFBF2C5" Offset="0.004"/>
								<GradientStop Color="#FFFFD200" Offset="1"/>
							</LinearGradientBrush>
						</Rectangle.Fill>
						<Rectangle.BitmapEffect>
							<DropShadowBitmapEffect ShadowDepth="2" Opacity=".6"  Softness="0.2"/>
						</Rectangle.BitmapEffect>			
					</Rectangle>						
					<ContentPresenter Margin="10,0,10,0" HorizontalAlignment="Center" VerticalAlignment="Center" TextBlock.Foreground="Black" TextBlock.FontSize="11"/>
					<TextBlock Margin="10,0,10,0" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding ToolTip.Content}" />
				</Grid>
			</ControlTemplate>
		</Setter.Value>
	</Setter>
        <Setter Property="FontFamily" Value="Arial"></Setter>
</Style>


And in app.xaml file of the project i'm using following codes:
(My Resources are in the Solution folder Named "Controls" in the same project)

C#
<Application.Resources>
         
    	<ResourceDictionary>
    		<ResourceDictionary.MergedDictionaries>
                   <ResourceDictionary Source="Controls\ToolTip.xaml"/>
    		</ResourceDictionary.MergedDictionaries>    		
    	</ResourceDictionary>
         
    </Application.Resources>


Kindly suggest. !!
Posted
Updated 14-Jul-13 23:46pm
v2

may be you mentioned the wrong path
it should be something like this
HTML
<resourcedictionary source="Themes<b>/</b>Dictionary1.xaml" />

Use appropriate slash symbol

Specify a unique name as a Key for the style like
HTML
<Style x:Key="tooltipStyle" TargetType="{x:Type Tooltip}">


and apply this style to the tooltip
 
Share this answer
 
v2
if you want to restyle all tooltips in application, remove x:Key from your style definition. If you want to restyle some specific tooltip, you should set tooltip style explicitly using StaticResource or DynamicResource markup extension.
And sure, you should check whether you set correct path when merged your dictionary into application resources
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900