1 回答
TA贡献1844条经验 获得超8个赞
要检查单击了哪个按钮,您应该DialogResult在 DialogWindow 中分配:
private void YesLogoutBtn_Click(object sender, RoutedEventArgs e)
{
DialogResult = true;
this.Close();
}
private void NoLogoutBtn_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
this.Close();
}
现在 make 方法在您的 MainWindow 中调用对话框并将其作为参数传递给 Page1:
private void AskDialog()
{
Dialog dialog = new Dialog();
if (dialog.ShowDialog() == true)
{
mainFrame.Content = null;
}
else
{
// False action
}
}
private void button1_Click(object sender, RoutedEventArgs e)
{
frame.Content = new Page1(AskDialog);
}
在 Page1 中,只需在按下按钮后调用此操作:
public User_Homepage(Action askDialog)
{
InitializeComponent();
AskDialog = askDialog;
}
private readonly Action AskDialog;
private void UserLogoutBtn_Click(object sender, RoutedEventArgs e)
{
AskDialog();
}
- 1 回答
- 0 关注
- 103 浏览
添加回答
举报