Window shown event in WPF?

前端 未结 1 1169
时光说笑
时光说笑 2020-12-09 15:48

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 e

相关标签:
1条回答
  • 2020-12-09 15:57

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

        bool _shown;
    
        protected override void OnContentRendered(EventArgs e)
        {
            base.OnContentRendered(e);
    
            if (_shown)
                return;
    
            _shown = true;
    
            // Your code here.
        }
    
    0 讨论(0)
提交回复
热议问题