fix(controls): Tooltips, context menu, and comboboxes drop shadow#1472
Conversation
|
@pomianowski best viewed without whitespace changes: |
|
Have you considered adding this change to ComboBoxes as well? I believe all you need is the following: EDIT: Seems like wrapping the ComboBox popup in EffectThicknessDecorator breaks its animation a bit for some reason.. Might need some additional changes so feel free to ignore me 😓 |
Yes, with animations there are some issues due to added margins, and the translation gets rendered above the combobox. There are some possibilities:
I'll commit some changes for this. |
Add Animation stuff.
|
|
||
| namespace Wpf.Ui.Controls; | ||
|
|
||
| public class EffectThicknessDecorator : Decorator |
There was a problem hiding this comment.
Consider giving this class a doc block (explaining the purpose) that effectively repeats this part from the PR:
This is because effects get clipped. [..] The solution is to add a decorator that wraps around it.
|
Is it because of this PR that makes context menu's text looks blurry? |
No. |
|
Looks like the |
|
Have you changed UseLayoutRounding or SnapsToDevicePixels somewhere? <StackPanel
ClipToBounds="True"
IsItemsHost="True"
KeyboardNavigation.DirectionalNavigation="Cycle"
Orientation="Vertical"
SnapsToDevicePixels="True"
UseLayoutRounding="True" /> |
|
Alternative idea in ContextMenu.xaml: <Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContextMenu}">
<controls:EffectThicknessDecorator Thickness="30">
<Grid x:Name="Grid">
<Grid.RenderTransform>
<TranslateTransform />
</Grid.RenderTransform>
<Border
x:Name="Border"
Padding="0,3,0,3"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="1"
CornerRadius="8">
<Border.Effect>
<DropShadowEffect
BlurRadius="20"
Direction="270"
Opacity="0.135"
ShadowDepth="10"
Color="#202020" />
</Border.Effect>
</Border>
<StackPanel
Margin="1,4,1,4"
ClipToBounds="True"
IsItemsHost="True"
KeyboardNavigation.DirectionalNavigation="Cycle"
Orientation="Vertical" />
</Grid>
</controls:EffectThicknessDecorator>
<ControlTemplate.Triggers>
<Trigger Property="IsOpen" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="Grid"
Storyboard.TargetProperty="(Grid.RenderTransform).(TranslateTransform.Y)"
From="-90"
To="0"
Duration="00:00:00.167">
<DoubleAnimation.EasingFunction>
<CircleEase EasingMode="EaseOut" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
|
|
As I explore further, I found the issue happens only on a WPF window that is NOT extending |
Try setting this in your Window: SnapsToDevicePixels="True"
UseLayoutRounding="True" |
Thanks, this did solve the problem. |








Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Currently, the drop shadow used by tooltips and context menus are broken. This is because effects get clipped.

What is the new behavior?
The solution is to add a decorator that wraps around it. I also updated the dropshadows to follow original colors (they were far too dark). The tooltips have less shadow than context menus in WinUI.