---
title: "How to fading out a wpf window during close"  
description: "How to fading out a wpf window during close"  
author: "Andrew Deniel"  
published: 2013-07-18  
updated: 2013-07-18  
canonical: https://www.mindstick.com/forum/1320/how-to-fading-out-a-wpf-window-during-close  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# How to fading out a wpf window during close

Hi [mindstick](https://yourviews.mindstick.com/view/84668/how-mindstick-is-used-for-marketing-purposes)!

I want to fade a [window](https://www.mindstick.com/forum/161285/how-does-the-window-console-object-work-in-javascript) in/out in my application. Fading in occurs on Window.Loaded and I wanted to fade out on [close](https://yourviews.mindstick.com/story/1687/rubbing-hands-close-up-benefits) (Window.Closed or Window.Closing). Fading in works perfectly but a RoutedEvent is not allowed on Window.Closing. What RoutedEvent should I be using for Close?

<Window.Triggers>

<EventTrigger RoutedEvent="Window.Loaded">

<BeginStoryboard>

<Storyboard>

<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" [Duration](https://answers.mindstick.com/qa/45301/what-is-a-short-duration-discussion)="0:0:2" FillBehavior="HoldEnd" />

</Storyboard>

</BeginStoryboard>

</EventTrigger>

<EventTrigger RoutedEvent="Window.Closing">

<BeginStoryboard>

<Storyboard>

<DoubleAnimation Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="0:0:2" FillBehavior="HoldEnd" />

</Storyboard>

</BeginStoryboard>

</EventTrigger>

</Window.Triggers>

I get a [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing) on , [Value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) 'Window.Closing' cannot be assigned to [property](https://www.mindstick.com/blog/205/property-notification-in-c-sharp) 'RoutedEvent'. Invalid [event](https://www.mindstick.com/articles/167719/marquee-hire-benefits-of-event-lighting-hire-london) name.

thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)

## Replies

### Reply by shreesh chandra shukla

Solution!

Closing is not a routed event, so you can't use it in an EventTrigger. Perhaps you could start the storyboard in the handler of the ClosingEvent in the code-behind and cancel the event... something like that :

```
private bool closeStoryBoardCompleted = false;private void Window_Closing(object sender, CancelEventArgs
e){    if
(!closeStoryBoardCompleted)    {       
closeStoryBoard.Begin();        e.Cancel =
true;    }}private void closeStoryBoard_Completed(object sender,
EventArgs e){    closeStoryBoardCompleted
= true;    this.Close();}
```


---

Original Source: https://www.mindstick.com/forum/1320/how-to-fading-out-a-wpf-window-during-close

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
