File tree Expand file tree Collapse file tree 2 files changed +5
-8
lines changed
Microsoft.Toolkit.Uwp.SampleApp/SamplePages
Microsoft.Toolkit.Uwp.UI/Extensions/UIElement Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Original file line number Diff line number Diff line change 1073
1073
"Name" : " ClipToBounds" ,
1074
1074
"Type" : " ClipToBoundsPage" ,
1075
1075
"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 " ,
1077
1077
"XamlCodeFile" : " ClipToBoundsCode.bind" ,
1078
1078
"Icon" : " /Assets/Helpers.png" ,
1079
1079
"DocumentationUrl" : " https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/extensions/UIElementExtensions.md"
Original file line number Diff line number Diff line change @@ -37,15 +37,12 @@ public static class UIElementExtensions
37
37
38
38
private static void OnClipToBoundsPropertyChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
39
39
{
40
- var element = d as UIElement ;
41
- if ( element is null )
40
+ if ( d is UIElement element )
42
41
{
43
- return ;
42
+ var clipToBounds = ( bool ) e . NewValue ;
43
+ var visual = ElementCompositionPreview . GetElementVisual ( element ) ;
44
+ visual . Clip = clipToBounds ? visual . Compositor . CreateInsetClip ( ) : null ;
44
45
}
45
-
46
- var clipToBounds = ( bool ) e . NewValue ;
47
- var visual = ElementCompositionPreview . GetElementVisual ( element ) ;
48
- visual . Clip = clipToBounds ? visual . Compositor . CreateInsetClip ( ) : null ;
49
46
}
50
47
}
51
48
}
You can’t perform that action at this time.
0 commit comments