记录下来,以免时间长给忘记了 呵呵。
Window1.xaml.cs
private void Button_Click(object sender, RoutedEventArgs e)
{
Window2 w2 = new Window2(this.Top, this.Left);//this.Top,this.Left 作用是将当前父窗体的位置传给子窗体
if (w2.ShowDialog()==true)
{
text1.Text = w2.name;
}
}
}
Window2.xaml.cs
public string name;
public Window2(double x,double y)
{
InitializeComponent();
//启用‘Manual’属性后,可以手动设置窗体的显示位置
this.WindowStartupLocation = WindowStartupLocation.Manual;
this.Top = x;
this.Left = y;
}
private void but1_Click(object sender, RoutedEventArgs e)
{
name = "hlr";
this.DialogResult = true;
}