其实挺简单的:Save / Store Window Location

 

Step1: 加一个新的 User-Scoped setting:

Save / Store Window Location

 

Step2: Save Window Location

}

 

 Step3: Load Window Location

 

 sender, EventArgs e)
{
    try
    {
        Rect bounds 
= Properties.Settings.Default.WindowPosition;
        
this.Top = bounds.Top;
        
this.Left = bounds.Left;
        
// Restore the size only for a manually sized window.
        if (this.SizeToContent == SizeToContent.Manual)
        {
            
this.Width = bounds.Width;
            
this.Height = bounds.Height;
        }
        
else
        {
            
this.Width = 1024;
            
this.Height = 768;
        }
    }
    
catch
    {
        
this.Top = 0;
        
this.Left = 0;
        
this.Width = 1024;
        
this.Height = 768;
    }
}

 

 好了,搞定了.

 sender, EventArgs e)
{
    
try
    {
        Rect bounds 
= Properties.Settings.Default.WindowPosition;
        
this.Top = bounds.Top;
        
this.Left = bounds.Left;
        
// Restore the size only for a manually sized window.
        if (this.SizeToContent == SizeToContent.Manual)
        {
            
this.Width = bounds.Width;
            
this.Height = bounds.Height;
        }
        
else
        {
            
this.Width = 1024;
            
this.Height = 768;
        }
    }
    
catch
    {
        
this.Top = 0;
        
this.Left = 0;
        
this.Width = 1024;
        
this.Height = 768;
    }
}

相关文章:

  • 2021-08-04
  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
  • 2021-04-26
  • 2021-11-26
  • 2021-09-19
  • 2022-12-23
猜你喜欢
  • 2021-06-17
  • 2021-11-02
  • 2021-10-26
  • 2022-12-23
  • 2021-11-27
  • 2021-12-24
  • 2021-07-14
相关资源
相似解决方案