@@ -242,6 +242,11 @@ public static Visual ApplyDropShadow(
242
242
result . Size = size ;
243
243
result . Children . Add ( blurResult ) ;
244
244
245
+ // We need to transfer "IsVisible" property from source to result
246
+ // because result is now the root visual for both shadow and source.
247
+ // Otherwise "IsVisible" property will be applied only to source.
248
+ TransferIsVisibleProperty ( context , source , result ) ;
249
+
245
250
// Check if ShadowOnly can be false
246
251
if ( ! dropShadowEffect . IsShadowOnly . IsAlways ( true ) )
247
252
{
@@ -267,6 +272,37 @@ public static Visual ApplyDropShadow(
267
272
return result ;
268
273
}
269
274
275
+ static void TransferIsVisibleProperty ( TranslationContext context , Visual source , Visual target )
276
+ {
277
+ // Here we are transfering default value of "IsVisible" to target
278
+ target . IsVisible = source . IsVisible ;
279
+ source . IsVisible = null ;
280
+
281
+ // Here we are transfering "isVisible" animation to target
282
+ foreach ( var animator in source . Animators . ToList ( ) )
283
+ {
284
+ if ( animator . AnimatedProperty != nameof ( source . IsVisible ) )
285
+ {
286
+ continue ;
287
+ }
288
+
289
+ if ( animator . Animation is KeyFrameAnimation_ )
290
+ {
291
+ Animate . WithKeyFrame ( context , target , animator . AnimatedProperty , ( KeyFrameAnimation_ ) animator . Animation ) ;
292
+ }
293
+ else if ( animator . Animation is ExpressionAnimation )
294
+ {
295
+ Animate . WithExpression ( target , ( ExpressionAnimation ) animator . Animation , animator . AnimatedProperty ) ;
296
+ }
297
+ else
298
+ {
299
+ throw new ArgumentException ( "IsVisible animation should be KeyFrameAnimation_ or ExpressionAnimation" ) ;
300
+ }
301
+
302
+ source . StopAnimation ( animator . AnimatedProperty ) ;
303
+ }
304
+ }
305
+
270
306
static Vector3 VectorFromRotationAndDistance ( Rotation direction , double distance ) =>
271
307
VectorFromRotationAndDistance ( direction . Radians , distance ) ;
272
308
0 commit comments