WPF子窗口的关闭有关问题
WPF子窗口的关闭问题
我写了一个WPF,主窗口里面点击一个button出现一个子窗口,然后。。。明明调用了this.close()
//////////////////以下为子窗口的代码
[code=csharp
namespace UI
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
public string Input
{
get { return this.input.Text; }
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}
][/code]
///////////////主窗口
/////////////问题是
1.我希望在子窗口按下button之后就可以关闭子窗口
2.我希望在主窗口里面可以检测以下语句是否成功,调试会报错,可是生成之后不会报错啊:
int waveband = Convert.ToInt32(myout.Waveband);
/////////////////////下图,点击FINE却不会关闭窗口
------解决思路----------------------
ButtonClick关闭窗体没问题。打断点看看MainForm的buttonClick事件哪里有问题。myout这个对象哪里定义了?
------解决思路----------------------
Button_Click
这函数是双击按钮自动生成的,还是你手打的,确定它已经绑定到按钮上了?
我写了一个WPF,主窗口里面点击一个button出现一个子窗口,然后。。。明明调用了this.close()
//////////////////以下为子窗口的代码
[code=csharp
namespace UI
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
public string Input
{
get { return this.input.Text; }
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}
][/code]
///////////////主窗口
private void Button_Click_6(object sender, RoutedEventArgs e)
{
if (MyComboBox.Text==ComboItem1.Content)
{
ImformationText.Text = null;
ImformationText.Text += String.Format("\r\nyou have chosen One-wave-method. . . .\r\n");
Window1 win = new Window1();
win.ShowDialog(); //or win.Show() if you want to be able to interact with the MainWindow before the Ok button has been clicked
myout.Waveband = win.Input ;
ImformationText.Text += String.Format("\r\nwhat you input is {0}. . . .\r\n",myout.Waveband);
int waveband = Convert.ToInt32(myout.Waveband);
//do something
}
}
/////////////问题是
1.我希望在子窗口按下button之后就可以关闭子窗口
2.我希望在主窗口里面可以检测以下语句是否成功,调试会报错,可是生成之后不会报错啊:
int waveband = Convert.ToInt32(myout.Waveband);
/////////////////////下图,点击FINE却不会关闭窗口
------解决思路----------------------
ButtonClick关闭窗体没问题。打断点看看MainForm的buttonClick事件哪里有问题。myout这个对象哪里定义了?
------解决思路----------------------
Button_Click
这函数是双击按钮自动生成的,还是你手打的,确定它已经绑定到按钮上了?