繁体   English   中英

在WPF上显示MessageBox.Show

[英]MessageBox.Show on WPF

我真的不知道为什么Message.Box.Show无法正常工作。 我有必要的指令,例如使用System.Windows.Forms。

private void circle_Click(object sender, RoutedEventArgs e)
{
    choose r1 = new choose();

    int x = int.Parse(beginx.Text);
    int y = int.Parse(beginy.Text);
    int w = int.Parse(wid.Text);
    int h = int.Parse(hei.Text);

    if (!((x > canvas.ActualWidth) && (y > canvas.ActualHeight) && (x > canvas.ActualWidth) && h > (canvas.ActualHeight)))
    {
        r1.rectangle(x, y, w, h, canvas);
    }
    else
    {
        MessageBox.Show("Error");
    }
}

WPF具有System.Windows.MessageBox而不是System.Windows.Forms.MessageBox (类似于WinForms)。 两者都有非常相似的API。 您可以在MSDN中阅读有关此内容的更多信息。

抱歉,Message.Box.Show下面有红色下划线。 错误列表显示“ MessageBox”是“ System.Windows.Forms.MessageBox的元素与System.Windows.MessageBox的元素之间的歧义引用

删除代码文件顶部的System.Windows.Forms的using指令:

using System.Windows.Forms;

...或在代码中使用完全限定的类型名称:

System.Windows.MessageBox.Show("Error");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM