Skip to content

Commit 1a321b1

Browse files
committed
address PR comments
1 parent d8e65aa commit 1a321b1

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@
10731073
"Name": "ClipToBounds",
10741074
"Type": "ClipToBoundsPage",
10751075
"About": "Extension to clip the UIElement inner controls inside its bounds.",
1076-
"CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI/Extensions/FrameworkElement",
1076+
"CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI/Extensions/UIElement",
10771077
"XamlCodeFile": "ClipToBoundsCode.bind",
10781078
"Icon": "/Assets/Helpers.png",
10791079
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/extensions/UIElementExtensions.md"

Microsoft.Toolkit.Uwp.UI/Extensions/UIElement/UIElementExtensions.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,12 @@ public static class UIElementExtensions
3737

3838
private static void OnClipToBoundsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
3939
{
40-
var element = d as UIElement;
41-
if (element is null)
40+
if (d is UIElement element)
4241
{
43-
return;
42+
var clipToBounds = (bool)e.NewValue;
43+
var visual = ElementCompositionPreview.GetElementVisual(element);
44+
visual.Clip = clipToBounds ? visual.Compositor.CreateInsetClip() : null;
4445
}
45-
46-
var clipToBounds = (bool)e.NewValue;
47-
var visual = ElementCompositionPreview.GetElementVisual(element);
48-
visual.Clip = clipToBounds ? visual.Compositor.CreateInsetClip() : null;
4946
}
5047
}
5148
}

0 commit comments

Comments
 (0)