2012-07-12 59 views
17

私は下の画像のように私のWPFのツールチップを形にしたい:WPFツールチップを吹き出しのようにスタイルするには?

enter image description here

どのように私はこれを達成できますか?

+0

私は最近、同様の問題に出くわしたと私は助けるかもしれないと考えている2つのポストを作成:http://pmichaels.net/2016/04/01/tooltip-speech-bubbles/て、http:// pmichaels.net/2016/04/08/creating-a-speech-bubble-withrounded-corners/ –

答えて

42

使用このコード:

<Window x:Class="WpfApplication2.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" 
    x:Name="Window" 
    Title="MainWindow" 
    Width="640" 
    Height="480"> 

<Window.Resources> 

    <Style x:Key="{x:Type ToolTip}" TargetType="ToolTip"> 
     <Setter Property="OverridesDefaultStyle" Value="true" /> 
     <Setter Property="HasDropShadow" Value="True" /> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="ToolTip"> 
        <ed:Callout Name="Border" 
           Width="{TemplateBinding Width}" 
           Height="{TemplateBinding Height}" 
           MinWidth="100" 
           MinHeight="30" 
           Margin="0,0,0,50" 
           AnchorPoint="0,1.5" 
           Background="{StaticResource LightBrush}" 
           BorderBrush="{StaticResource SolidBorderBrush}" 
           BorderThickness="1" 
           CalloutStyle="RoundedRectangle" 
           Fill="#FFF4F4F5" 
           FontSize="14.667" 
           Stroke="Black"> 
         <ContentPresenter Margin="4" 
              HorizontalAlignment="Left" 
              VerticalAlignment="Top" /> 
        </ed:Callout> 

       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 

</Window.Resources> 
<Grid> 
    <Button ToolTip="Hello" /> 
</Grid> 

はこれが初めで、今あなたがそれをプレイしている...お楽しみください!

enter image description here

+0

ハリーに感謝します。私は別の質問があります:xmlns:ed = "http://schemas.microsoft.com/expression/2010/drawing"のアセンブリを追加する必要がありますか? –

+7

はい、Microsoft.Expression.Drawingアセンブリを追加します。 – Harry

+0

恐ろしい!鮮やかな仕事、間違いなく投票番号 –

0

新しいツールチップcontrol templateを作成できます。

+0

作業サンプルを投稿できますか?代わりの実装を見て興味深いだろう。 – Tim

関連する問題