[WPF 学习] 9.自定义一个Window的样子

基本思路是把原来的WindowStyle设置为None,然后自己弄一个标题栏

一、xmal


   
        
        
            
                M1,1  L1 ,11 L11,11 L11,1 z M0,0 L12,0 L12,12 L0,12 z
            
        
        
        
            
                M1,3 L1,11 L9,11 L9,3 z M3,1 L3,2 L10,2 L10,9 L11,9 L11,1 z M2 ,0 L12,0 L12,10 L10,10 L10,12 L0,12 L0,2 L2 ,2 z
            
        

    
    
        
            
            
        
        
            

                
                
                    
                        
                    
                


                

                    
                    
                    
                
            
        
        

        
    


二、后台代码(几个事件)

        private void BtnClose_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Shutdown();
        }

        private void BtnMax_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = this.WindowState != WindowState.Maximized ? WindowState.Maximized : WindowState.Normal;
        }

        private void BtnMin_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }

        private void WinMain_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            PMax.Data = this.WindowState == WindowState.Maximized ? Resources["pathRestore"] as Geometry : Resources["pathMaximize"] as Geometry;
        }

你可能感兴趣的:([WPF 学习] 9.自定义一个Window的样子)