@@ -52,6 +52,7 @@ static DashedBorder()
5252 BorderDashThicknessProperty ,
5353 BorderThicknessProperty
5454 ) ;
55+
5556 AffectsRender < DashedBorder > (
5657 BorderDashArrayProperty ,
5758 BorderDashCapProperty ,
@@ -60,6 +61,26 @@ static DashedBorder()
6061 BorderBrushProperty ,
6162 BackgroundProperty
6263 ) ;
64+
65+ BorderThicknessProperty . Changed . AddClassHandler < DashedBorder > ( OnClearPenCache ) ;
66+ BorderDashThicknessProperty . Changed . AddClassHandler < DashedBorder > ( OnClearPenCache ) ;
67+ BorderBrushProperty . Changed . AddClassHandler < DashedBorder > ( OnClearPenCache ) ;
68+ BackgroundProperty . Changed . AddClassHandler < DashedBorder > ( OnClearPenCache ) ;
69+ BorderDashArrayProperty . Changed . AddClassHandler < DashedBorder > ( OnClearPenCache ) ;
70+ BorderDashCapProperty . Changed . AddClassHandler < DashedBorder > ( OnClearPenCache ) ;
71+ BorderDashOffsetProperty . Changed . AddClassHandler < DashedBorder > ( OnClearPenCache ) ;
72+ }
73+
74+ private static void OnClearPenCache ( AvaloniaObject d , AvaloniaPropertyChangedEventArgs e )
75+ {
76+ var border = ( DashedBorder ) d ;
77+ border . _leftPenCache = null ;
78+ border . _rightPenCache = null ;
79+ border . _topPenCache = null ;
80+ border . _bottomPenCache = null ;
81+ border . _geometryPenCache = null ;
82+ border . _backgroundGeometryCache = null ;
83+ border . _borderGeometryCache = null ;
6384 }
6485
6586 public double BorderDashThickness
@@ -145,34 +166,6 @@ private void VerifyScale()
145166 _layoutThickness = new Thickness ? ( ) ;
146167 }
147168
148- protected override void OnPropertyChanged ( AvaloniaPropertyChangedEventArgs change )
149- {
150- base . OnPropertyChanged ( change ) ;
151-
152- string propertyName = change . Property . Name ;
153- if ( string . Equals ( propertyName , nameof ( BorderThickness ) ) ||
154- string . Equals ( propertyName , nameof ( BorderDashThickness ) ) ||
155- string . Equals ( propertyName , nameof ( BorderBrush ) ) ||
156- string . Equals ( propertyName , nameof ( Background ) ) ||
157- string . Equals ( propertyName , nameof ( BorderDashArray ) ) ||
158- string . Equals ( propertyName , nameof ( BorderDashCap ) ) ||
159- string . Equals ( propertyName , nameof ( BorderDashOffset ) ) )
160- {
161- ClearCache ( ) ;
162- }
163- }
164-
165- private void ClearCache ( )
166- {
167- _leftPenCache = null ;
168- _rightPenCache = null ;
169- _topPenCache = null ;
170- _bottomPenCache = null ;
171- _geometryPenCache = null ;
172- _backgroundGeometryCache = null ;
173- _borderGeometryCache = null ;
174- }
175-
176169 public override void Render ( DrawingContext context )
177170 {
178171 var radii = CornerRadius ;
0 commit comments