【发布时间】:2017-07-05 18:44:40
【问题描述】:
在我的 MainWindow.xaml 中,我有一个框架。当我单击按钮时,此框架的内容将发生变化。所以如果我点击一个按钮来显示私人客户,框架内容会显示私人客户的网站:
private void privatecustomer_Click(object sender, RoutedEventArgs e)
{
Main.Content = new Privatecustomer.privatecustomer_show();
}
单击此按钮后,框架将更改内容。 新内容现在显示 Privatecustomer.privatecustomer_show.xaml。 在这个 xaml 中,我有另一个按钮。如果我单击此按钮,MainWindow 中框架的内容应更改为“Privatecustomer.privatecustomer_add.xaml”。
但是我如何知道从 privatecustomer_show.xaml 到 MainWindow.xaml,点击了 privatecustomer_show 中的按钮 addPrivatecustomer 并且 Main.Content 必须更改为
Main.Content = new Privatecustomer.privatecustomer_add();
? 我希望我能在这里得到一些帮助
【问题讨论】:
-
在 privatecustomers_show.xaml 中:
public event EventHandler ButtonFirstFormClicked; public void addPrivatkunde(object sender, RoutedEventArgs e) { if (ButtonFirstFormClicked != null) ButtonFirstFormClicked(sender, e); }在 MainWindow.xaml 中:Privatecustomer.privatecustomer_show.ButtonFirstFormClicked += (s, e) { Main.Content = new Privatecustomer.privatecustomer_add(); }但这不起作用,因为 MainWindow 不知道Privatecustomer.privatecustomer_show.ButtonFirstFormClicked += (s, e) -
每次点击是处理同一个页面还是创建一个新页面?
-
你是什么意思?我有我的 MainWindow.xaml。有一个框架显示我想查看的页面。如果我单击 MainWindow 上的“私人客户”按钮。框架向我显示了来自 privatecustomers_show.xaml 的内容。这行得通。但是当我单击 privatecustomers_show 中的按钮时,我希望 MainWindow 中的 Frame.Content 更改为“Main.Content = new privatecustomer_add”。