1- using Microsoft . Maui . Controls . PlatformConfiguration ;
2- using Microsoft . Maui . Controls . PlatformConfiguration . iOSSpecific ;
3- using Microsoft . Maui . Controls . Shapes ;
4- using ListView = Microsoft . Maui . Controls . ListView ;
1+ using Microsoft . Maui . Controls . Shapes ;
52
63namespace Maui . Controls . Sample . Issues
74{
8-
95 [ Issue ( IssueTracker . Github , 27730 , "Shadow not updated when Clipping a View with a shadow" , PlatformAffected . UWP ) ]
106 public class Issue27730 : TestContentPage
117 {
8+ Border _borderWithShadow ;
9+ Border _normalBorder ;
10+
1211 protected override void Init ( )
1312 {
14- VerticalStackLayout rootLayout = new VerticalStackLayout ( )
13+ VerticalStackLayout rootLayout = new VerticalStackLayout
1514 {
1615 Spacing = 10 ,
1716 Padding = 10
1817 } ;
19- Border BorderShadow = new Border ( )
18+
19+ Label shadowLabel = new Label { Text = "Border with Shadow, Clipping applied at runtime" } ;
20+ Label clipLabel = new Label { Text = "Normal Border without shadow, Clipping first, Shadow added later" } ;
21+
22+ _borderWithShadow = CreateBorder ( true ) ;
23+ _normalBorder = CreateBorder ( false ) ;
24+
25+ Button applyClipButton = new Button { Text = "Apply Clip" , AutomationId = "ApplyClipBtn" } ;
26+ Button applyShadowButton = new Button { Text = "Apply Shadow" , AutomationId = "ApplyShadowBtn" } ;
27+
28+ applyClipButton . Clicked += ( s , e ) => ApplyClip ( ) ;
29+ applyShadowButton . Clicked += ( s , e ) => ApplyShadow ( ) ;
30+
31+ rootLayout . Add ( shadowLabel ) ;
32+ rootLayout . Add ( _borderWithShadow ) ;
33+ rootLayout . Add ( clipLabel ) ;
34+ rootLayout . Add ( _normalBorder ) ;
35+ rootLayout . Add ( applyClipButton ) ;
36+ rootLayout . Add ( applyShadowButton ) ;
37+ Content = rootLayout ;
38+ }
39+
40+ private Border CreateBorder ( bool withShadow )
41+ {
42+ return new Border
2043 {
2144 StrokeShape = new RoundRectangle { CornerRadius = new CornerRadius ( 24 ) } ,
2245 Background = Colors . Red ,
2346 WidthRequest = 100 ,
2447 HeightRequest = 100 ,
2548 Margin = new Thickness ( 12 , 0 ) ,
26- Shadow = new Shadow ( )
49+ Shadow = withShadow ? new Shadow
2750 {
2851 Brush = Colors . Black ,
2952 Offset = new Point ( 12 , 12 ) ,
3053 Radius = 10 ,
3154 Opacity = 1
32- }
33- } ;
34- Button button = new Button ( )
35- {
36- AutomationId = "ApplyClipBtn" ,
37- Text = "Apply Clip" ,
55+ } : null
3856 } ;
57+ }
3958
40- button . Clicked += ( s , e ) =>
59+ private void ApplyClip ( )
60+ {
61+ EllipseGeometry clipGeometry = new EllipseGeometry
4162 {
42- BorderShadow . Clip = new EllipseGeometry
43- {
44- Center = new Point ( 50 , 50 ) ,
45- RadiusX = 25 ,
46- RadiusY = 25
47- } ;
63+ Center = new Point ( 50 , 50 ) ,
64+ RadiusX = 25 ,
65+ RadiusY = 25
4866 } ;
4967
50- rootLayout . Add ( BorderShadow ) ;
51- rootLayout . Add ( button ) ;
52- Content = rootLayout ;
68+ _borderWithShadow . Clip = clipGeometry ;
69+ _normalBorder . Clip = clipGeometry ;
70+ }
5371
72+ private void ApplyShadow ( )
73+ {
74+ _normalBorder . Shadow = new Shadow
75+ {
76+ Brush = Colors . Black ,
77+ Offset = new Point ( 12 , 12 ) ,
78+ Radius = 10 ,
79+ Opacity = 1
80+ } ;
5481 }
5582 }
5683}
0 commit comments