gpt4 book ai didi

c# - 如何在我的工具提示上获得更厚的阴影?

转载 作者:太空宇宙 更新时间:2023-11-03 11:28:43 25 4
gpt4 key购买 nike

我用以下内容覆盖了我的工具提示:

<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>

边距的 Thickness 值似乎有最大值 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 的边距,我仍然没有得到更厚的阴影。

最佳答案

margin 不受限制。要查看更多阴影,您需要将边距应用到 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)。如果没有通过某些触发器或其他方式改变这一点,您将看不到任何阴影。

关于c# - 如何在我的工具提示上获得更厚的阴影?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8531317/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com