我使用以下方法覆盖了我的工具提示:

<Style x:Key="{x:Type ToolTip}" TargetType="ToolTip">
    <Setter Property="OverridesDefaultStyle" Value="True"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ToolTip">
                <Grid>
                    <Grid.Background>
                        <SolidColorBrush />
                    </Grid.Background>
                    <mwt:SystemDropShadowChrome Color="#00FFFFFF" CornerRadius="5" Name="Shdw" SnapsToDevicePixels="True">
                        <Border CornerRadius="5">
                            <StackPanel>
                                <ContentPresenter TextBlock.Foreground="Black" />
                            </StackPanel>
                        </Border>
                    </mwt:SystemDropShadowChrome>
                </Grid>


边距的“厚度”值似乎最大值为5?

                <ControlTemplate.Triggers>
                    <Trigger Property="ToolTipService.HasDropShadow">
                        <Setter Property="FrameworkElement.Margin" TargetName="Shdw">
                            <Setter.Value>
                                <Thickness>0,0,5,5</Thickness>
                            </Setter.Value>
                        </Setter>
                        <Trigger.Value>
                            <sys:Boolean>True</sys:Boolean>
                        </Trigger.Value>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>


能够看到更多投影效果很好。

我不好,因为没有发布我所有的代码。这是根据icebat的响应进行的编辑:

<Style x:Key="{x:Type ToolTip}" TargetType="ToolTip">
    <Setter Property="OverridesDefaultStyle" Value="True"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ToolTip">
                <Grid>
                    <Grid.Background>
                        <SolidColorBrush />
                    </Grid.Background>
                    <mwt:SystemDropShadowChrome Color="#71000000" CornerRadius="5" Name="Shdw" SnapsToDevicePixels="True">
                        <Border CornerRadius="5">
                            <StackPanel>
                                <ContentPresenter TextOptions.TextRenderingMode="ClearType" TextOptions.TextFormattingMode="Display" TextBlock.FontFamily="Segoe UI" TextBlock.FontStretch="Normal" TextBlock.FontWeight="Normal" TextBlock.Foreground="Black" TextBlock.FontSize="13" Margin="18,8,16,4" HorizontalAlignment="Left" VerticalAlignment="Top" />
                                <Border HorizontalAlignment="Stretch" BorderThickness="0,1,0,0" BorderBrush="Gray" Margin="10,5,10,5"  Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2">
                                    <TextBlock Margin="8,4,0,0" FontWeight="Bold" Text="{x:Static res:AppStrings.Help_0_Footer}" FontSize="13" Foreground="#E3000000" />
                                </Border>
                            </StackPanel>
                            <Border.Background>
                                <LinearGradientBrush>
                                    <LinearGradientBrush.StartPoint>
                                        <Point X=".5" Y="0"/>
                                    </LinearGradientBrush.StartPoint>
                                    <LinearGradientBrush.EndPoint>
                                        <Point X=".5" Y="1"/>
                                    </LinearGradientBrush.EndPoint>
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStop Color="#FFFFA200" Offset="1"/>
                                        <GradientStop Color="White" Offset="0.305"/>
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>
                    </mwt:SystemDropShadowChrome>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="ToolTipService.HasDropShadow" Value="True">
                        <Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>


我仍然没有获得比5更大的边距的较浓的阴影。

最佳答案

保证金不限。要查看更多阴影,您需要将余量不应用于SystemDropShadowChrome装饰器本身,而应应用于其内容:

<mwt:SystemDropShadowChrome Name="Shdw" CornerRadius="5">
    <Border Name="shdwContent" CornerRadius="5">
         <StackPanel>
             <ContentPresenter TextBlock.Foreground="Black" />
         </StackPanel>
    </Border>
</mwt:SystemDropShadowChrome>
...
<ControlTemplate.Triggers>
    <Trigger Property="ToolTipService.HasDropShadow" Value="True">
        <Setter Property="Margin" TargetName="ShdwContent" Value="0,0,5,5">
    </Trigger>
</ControlTemplate.Triggers>


另外,现在您将透明色用作阴影色(#00FFFFFF)。如果未通过某些触发器或其他方式更改该设置,则不会看到任何阴影。

10-07 19:12
查看更多