Skip to content

Commit 0440794

Browse files
committed
update to the latest store version
1 parent c2d6602 commit 0440794

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

components/OpacityMaskView/samples/OpacityMaskViewSample.xaml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,27 @@
1111
<StackPanel Spacing="12">
1212
<controls:OpacityMaskView>
1313
<controls:OpacityMaskView.OpacityMask>
14-
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
15-
<GradientStop Offset="0" Color="White" />
16-
<GradientStop Offset="1" Color="Transparent" />
17-
</LinearGradientBrush>
14+
<Rectangle>
15+
<Rectangle.Fill>
16+
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
17+
<GradientStop Offset="0" Color="White" />
18+
<GradientStop Offset="1" Color="Transparent" />
19+
</LinearGradientBrush>
20+
</Rectangle.Fill>
21+
</Rectangle>
1822
</controls:OpacityMaskView.OpacityMask>
1923
<Button Content="Hello Windows Community Toolkit" />
2024
</controls:OpacityMaskView>
2125
<controls:OpacityMaskView>
2226
<controls:OpacityMaskView.OpacityMask>
23-
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
24-
<GradientStop Offset="0" Color="White" />
25-
<GradientStop Offset="0.6" Color="Transparent" />
26-
</LinearGradientBrush>
27+
<Rectangle>
28+
<Rectangle.Fill>
29+
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
30+
<GradientStop Offset="0" Color="White" />
31+
<GradientStop Offset="0.6" Color="Transparent" />
32+
</LinearGradientBrush>
33+
</Rectangle.Fill>
34+
</Rectangle>
2735
</controls:OpacityMaskView.OpacityMask>
2836
<Border Width="96"
2937
Height="96"

components/OpacityMaskView/src/OpacityMaskView.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ namespace CommunityToolkit.WinUI.Controls;
1919
/// A control that applies an opacity mask to its content.
2020
/// </summary>
2121
[TemplatePart(Name = RootGridTemplateName, Type = typeof(Grid))]
22-
[TemplatePart(Name = MaskRectangleTemplateName, Type = typeof(Rectangle))]
22+
[TemplatePart(Name = MaskContainerTemplateName, Type = typeof(Border))]
2323
[TemplatePart(Name = ContentPresenterTemplateName, Type = typeof(ContentPresenter))]
2424
public partial class OpacityMaskView : ContentControl
2525
{
2626
/// <summary>
2727
/// Identifies the <see cref="OpacityMask"/> property.
2828
/// </summary>
2929
public static readonly DependencyProperty OpacityMaskProperty =
30-
DependencyProperty.Register(nameof(OpacityMask), typeof(Brush), typeof(OpacityMaskView), new PropertyMetadata(null, OnOpacityMaskChanged));
30+
DependencyProperty.Register(nameof(OpacityMask), typeof(UIElement), typeof(OpacityMaskView), new PropertyMetadata(null, OnOpacityMaskChanged));
3131

3232
private const string ContentPresenterTemplateName = "PART_ContentPresenter";
33-
private const string MaskRectangleTemplateName = "PART_MaskRectangle";
33+
private const string MaskContainerTemplateName = "PART_MaskContainer";
3434
private const string RootGridTemplateName = "PART_RootGrid";
3535

3636
#if WINDOWS_WINAPPSDK
@@ -50,11 +50,11 @@ public OpacityMaskView()
5050
}
5151

5252
/// <summary>
53-
/// Gets or sets an opacity mask, as a <see cref="Brush"/> implementation that is applied to any alpha-channel masking for the rendered content of the content.
53+
/// Gets or sets a <see cref="UIElement"/> as the opacity mask that is applied to alpha-channel masking for the rendered content of the content.
5454
/// </summary>
55-
public Brush? OpacityMask
55+
public UIElement? OpacityMask
5656
{
57-
get => (Brush?)GetValue(OpacityMaskProperty);
57+
get => (UIElement?)GetValue(OpacityMaskProperty);
5858
set => SetValue(OpacityMaskProperty, value);
5959
}
6060

@@ -65,11 +65,11 @@ protected override void OnApplyTemplate()
6565

6666
Grid rootGrid = (Grid)GetTemplateChild(RootGridTemplateName);
6767
ContentPresenter contentPresenter = (ContentPresenter)GetTemplateChild(ContentPresenterTemplateName);
68-
Rectangle maskRectangle = (Rectangle)GetTemplateChild(MaskRectangleTemplateName);
68+
Border maskContainer = (Border)GetTemplateChild(MaskContainerTemplateName);
6969

7070
_maskBrush = _compositor.CreateMaskBrush();
7171
_maskBrush.Source = GetVisualBrush(contentPresenter);
72-
_mask = GetVisualBrush(maskRectangle);
72+
_mask = GetVisualBrush(maskContainer);
7373
_maskBrush.Mask = OpacityMask is null ? null : _mask;
7474

7575
SpriteVisual redirectVisual = _compositor.CreateSpriteVisual();
@@ -105,7 +105,7 @@ private static void OnOpacityMaskChanged(DependencyObject d, DependencyPropertyC
105105
return;
106106
}
107107

108-
Brush? opacityMask = (Brush?)e.NewValue;
108+
UIElement? opacityMask = (UIElement?)e.NewValue;
109109
maskBrush.Mask = opacityMask is null ? null : self._mask;
110110
}
111111
}

components/OpacityMaskView/src/OpacityMaskView.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
1+
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
22
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:local="using:CommunityToolkit.WinUI.Controls">
@@ -17,9 +17,9 @@
1717
<Grid x:Name="PART_RootGrid"
1818
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
1919
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
20-
<Rectangle x:Name="PART_MaskRectangle"
21-
Fill="{TemplateBinding OpacityMask}"
22-
IsHitTestVisible="False" />
20+
<Border x:Name="PART_MaskContainer"
21+
Child="{TemplateBinding OpacityMask}"
22+
IsHitTestVisible="False" />
2323
<ContentPresenter x:Name="PART_ContentPresenter"
2424
Content="{TemplateBinding Content}"
2525
ContentTemplate="{TemplateBinding ContentTemplate}" />

0 commit comments

Comments
 (0)