Fading out a window

前端 未结 3 1860
余生分开走
余生分开走 2020-12-08 05:35

I am currently developing a wpf c# application. I have added to event triggers to the xaml of the form to fade in when the window loads and fades out when the window closes.

3条回答
  •  猫巷女王i
    2020-12-08 06:04

    just try this sample

    
    
        
            
                
                    
                
            
        
        
            
                
                    
                
            
        
        
    
    
    
    

    namespace FadeInAndOutWindow
    {
        public partial class Window1 : Window
        {
            public Window1()
            {
                InitializeComponent();
            }
    
            private bool closeCompleted = false;
    
    
            private void FormFadeOut_Completed(object sender, EventArgs e)
            {
                closeCompleted = true;
                this.Close();
            }
    
            private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
            {
    
                if (!closeCompleted)
                {
                    FormFadeOut.Begin();
                    e.Cancel = true;
                }
            }
    
        }
    }
    

提交回复
热议问题