如果你把这看作是一个 question问题,那么我仍然处在 c的学习阶段。
在该项目中,我有主要窗口和一个称为“窗口1”的新窗口。
在主线上,我有一个县,它就象窗口1那样:
private void Button_Click(object sender, RoutedEventArgs e)
{
Window1 W1 = new Window1();
W1.Show();
this.Close();
}
现在,这项工作按预期进行,创造了新的窗口1,并在关闭主窗时展示。
但这里的捕获量是:在窗口1中,有些 st子可能改变,就像用户点击的纽顿一样,然后当新显示时,纽芬兰藏匿。
我还在窗口1上打了背顿语,使用与上述相同的代码回馈主寡妇(现为新的窗口1,但新主窗口)。
But at this point, when I click in main, on the button again to go to window1, that window1 is back to default state. Seems logical to me because it creates a new instance when using the button.
但是,如果我想再次打开窗口1的首例,即用户已经改变的窗口,那么我怎么办?
首先,我想将<条码>Window1 W1 = 新的窗口1(a);置于纽伦方法之外,但这也因为“背”纽扣而赢得了t工作。
我希望我能充分解释我想要做的事情。
任何想法都是这样?
====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
EDIT:
using the code example from "chrfin" some parts genarate errors, like the "visible = true" part maybe this is because i use express 2010 or it is because i use WPF and not forms?
in the main:
Window1 W1 = null; // Initialise Field.
private void CalcTabel_Click(object sender, RoutedEventArgs e)
{
if (W1 == null)
{
W1 = new Window1();
W1.MainWindow = this; //ERROR
W1.Show();
}
else
W1.Visibility = Visibility.Visible;
this.Visibility = Visibility.Hidden;
}
页: 1
public MainWindow w1 { get; set; }
private void Quit_Click(object sender, RoutedEventArgs e)
{
w1.Visibility = Visibility.Visible;
this.Visibility = Visibility.Hidden;
}
now the error that i get on the main part is: WpfApplication1.Window1 does not contain a definition for MainWindow accepting a first argument of type WpfApplication1.Window1 could be found(are you missing a using directive or an assembly reference?)
仅仅删除这一错误线,就会造成结果,使部分人无法得到任何东西。
any ideas ?
====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
EDIT:
Thanx again "chrfin" got it working now :)
主要内容是:
Window1 W1 = null; // Initialise Field.
private void CalcTabel_Click(object sender, RoutedEventArgs e)
{
if (W1 == null)
{
W1 = new Window1();
W1.Hoofdmenu = this;
W1.Show();
}
else
W1.Visibility = Visibility.Visible;
this.Visibility = Visibility.Hidden;
}
:
public MainWindow Hoofdmenu { get; set; }
private void Quit_Click(object sender, RoutedEventArgs e)
{
Hoofdmenu.Visibility = Visibility.Visible;
this.Visibility = Visibility.Hidden;
}
- Solved -