Skip to content

Commit 43de39a

Browse files
committed
Add support for custom shadow alpha masks
1 parent 0cb2ea6 commit 43de39a

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

Microsoft.Toolkit.Uwp.UI.Controls.Core/DropShadowPanel/DropShadowPanel.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using Microsoft.Toolkit.Uwp.UI.Controls.Core.DropShadowPanel;
56
using System;
67
using System.Numerics;
7-
using System.Threading.Tasks;
88
using Windows.UI;
99
using Windows.UI.Composition;
1010
using Windows.UI.Xaml;
@@ -168,7 +168,11 @@ private void UpdateShadowMask()
168168
{
169169
CompositionBrush mask = null;
170170

171-
if (Content is Image)
171+
if (Content is IAlphaMaskProvider maskedControl)
172+
{
173+
mask = maskedControl.GetAlphaMask();
174+
}
175+
else if (Content is Image)
172176
{
173177
mask = ((Image)Content).GetAlphaMask();
174178
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Windows.UI.Composition;
2+
3+
namespace Microsoft.Toolkit.Uwp.UI.Controls.Core.DropShadowPanel
4+
{
5+
/// <summary>
6+
/// Any user control can implement this interface to provide a custom alpha mask to it's parent <see cref="DropShadowPanel"/>
7+
/// </summary>
8+
public interface IAlphaMaskProvider
9+
{
10+
/// <summary>
11+
/// This method should return the appropiate alpha mask to be used in the shadow of this control
12+
/// </summary>
13+
/// <returns>The alpha mask as a composition brush</returns>
14+
CompositionBrush GetAlphaMask();
15+
}
16+
}

0 commit comments

Comments
 (0)