Skip to content

Commit cc498be

Browse files
authored
[Windows] Allow to remove shadows at runtime (#31452)
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change This PR attempts to address https://github.com/dotnet/maui/pull/18337/files#r2314339635. That is, it makes sure that shadow is removed from Border when `Border.Shadow = null` is assigned. I took inspiration in Android implementation: https://github.com/dotnet/maui/blob/718adb7f4f9ad83bcd3ead1627b6fba329837b2a/src/Core/src/Platform/Android/WrapperView.cs#L61-L110 ### Test effect My `src\Controls\tests\TestCases.WinUI.Tests\snapshots\windows\Issue24414Test_5.png` changes like this: | Before | After | |--------|--------| | <img width="1010" height="729" alt="image" src="https://github.com/user-attachments/assets/13e70b02-acab-4ef2-a4d0-f799d60748d2" /> | <img width="1264" height="952" alt="image" src="https://github.com/user-attachments/assets/865c4f68-ef05-4d25-a5c6-14c5d96a4872" />|
2 parents 7ff5fc9 + 326ee2b commit cc498be

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed
-9.63 KB
Loading

src/Core/src/Platform/Windows/WrapperView.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,20 @@ void UpdateBorder()
167167

168168
partial void ShadowChanged()
169169
{
170-
if (HasShadow)
170+
if (Shadow?.Paint is { })
171171
{
172-
UpdateShadowAsync().FireAndForget(IPlatformApplication.Current?.Services?.CreateLogger(nameof(WrapperView)));
172+
if (HasShadow)
173+
{
174+
UpdateShadowAsync().FireAndForget(IPlatformApplication.Current?.Services?.CreateLogger(nameof(WrapperView)));
175+
}
176+
else
177+
{
178+
CreateShadowAsync().FireAndForget(IPlatformApplication.Current?.Services?.CreateLogger(nameof(WrapperView)));
179+
}
173180
}
174181
else
175182
{
176-
CreateShadowAsync().FireAndForget(IPlatformApplication.Current?.Services?.CreateLogger(nameof(WrapperView)));
183+
DisposeShadow();
177184
}
178185
}
179186

0 commit comments

Comments
 (0)