1
窗口中有一個按鈕btn_Edit
。點擊該按鈕後,會打開一個新窗口(new_win
),並將點擊事件添加到new_win
上的按鈕(btn_OK
)。看起來btn_OK_Click
不起作用,因爲new_win
沒有關閉。哪裏有問題?WPF中的事件處理
BC_edit new_win = new BC_edit();
private void btn_Edit_Click(object sender, RoutedEventArgs e)
{
new_win.Title = "a_title";
new_win.ShowDialog();
new_win.btn_OK.Click += new RoutedEventHandler(btn_OK_Click);
}
private void btn_OK_Click(object sender, RoutedEventArgs e)
{
_MyCollection.Add(new MyData
{
Boundary = new_win.Title,
Type = new_win.cmb_BC_edit_type.SelectedItem.ToString(),
Option = new_win.cmb_BC_edit_options.SelectedItem.ToString()
});
new_win.Close();
}