2012-09-26 74 views
0

我已經創建了自定義模板下面的自定義工具提示。Silverlight的設置自定義工具提示編程

<ToolTip x:Class="FireFly.Controls.CustomToolTip" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
mc:Ignorable="d" 
d:DesignHeight="300" d:DesignWidth="400"> 
<ToolTip.Style> 
    <Style TargetType="ToolTip"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="ToolTip"> 
        <Border> 
         <Border.Background> 
          <RadialGradientBrush> 
           <GradientStop Color="WhiteSmoke"/> 
           <GradientStop Color="#FFE0E0E0" Offset="1"/> 
          </RadialGradientBrush> 
         </Border.Background> 
         <ContentPresenter Content="{TemplateBinding Content}" 
           ContentTemplate="{TemplateBinding ContentTemplate}" 
           Margin="{TemplateBinding Padding}" 
           VerticalAlignment="Center"/> 
        </Border> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
</ToolTip.Style>  

什麼,我需要做的是,從behvior內我需要將連結的本對象的工具提示設置爲我的自定義工具提示控件的一個實例。

喜歡的東西

toolTip = new CustomToolTip() {Content = new TextBlock() {Text = text, FontSize = 12}}; 

但是這是行不通的。

可能有人可能指向我的方向是正確的?

感謝

史蒂夫

+0

它應該是足夠寫'theAssociatedObject.ToolTip =新CustomToolTip()' – McGarnagle

回答

0

我使用其他第三方工具提示提供商。 .NET框架中內置的一個不夠好。