C# – Window shown event in WPF


I want to apply fade animation every time my window is shown. How to do that from xaml? That window can be hidden and then shown again so I can't use Loaded event.

Best Solution

You can use the ContentRendered event or override OnContentRendered virtual method like this:

    bool _shown;

    protected override void OnContentRendered(EventArgs e)

        if (_shown)

        _shown = true;

        // Your code here.