Common Tooltip style in WPF

Can I make a tooltip style which can be applied to all tooltips for every control.

I tried this.

<Style TargetType="{x:Type ToolTip}" >
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="HasDropShadow" Value="True" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="FontSize" Value="12" />
        <Setter Property="Placement" Value="Bottom" />
        <Setter Property="VerticalOffset" Value="0" />
        <Setter Property="Padding" Value="8" />

        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToolTip}" >
                    <StackPanel Margin="7,1" >
                      <Border Background="#FFF7F7CC" CornerRadius="1" >
                            <TextBlock Margin="1" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Top" Text="{TemplateBinding ToolTip}"/>
                        </Border>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

For Using this style I have to put a seperate Tooltip tag in control, eg to apply tooltip to border,

<Border>
    <Border.ToolTip>
          <ToolTip ToolTip="This is tooltip text"  />
    </Border.ToolTip>
........
.........
</Border>

but is there any way where tooltipstyle applies to all control with tooltip mentioned in same tag. eg.

<Border BorderBrush="Transparent" Background="Transparent" Cursor="Help" ToolTip="This is Tooltip" >
.....
.....
</Border>

let me know if any further details are required. Thanks in Anticipation.


链接地址: http://www.djcxy.com/p/14282.html

上一篇: 当文本换行到两行时,块元素占用全部宽度

下一篇: WPF中的通用工具提示风格