其实挺简单的:
Step1: 加一个新的 User-Scoped setting:
Step2: Save Window Location
Step3: Load Window Location
{
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;
}
}