相关疑难解决方法(0)

在进入poof之前,System.Windows.MessageBox不等待用户输入!

......这没有任何意义.TT

在我的Application_Startup事件处理程序中,我的代码看起来有点像这样:

private void Application_Startup(object sender, StartupEventArgs e)
{
    string errorMessage;

    if(CheckStartUpConditions(out errorMessage))
    {
        (new MainWindow()).Show();
    }
    else
    {
        MessageBox.Show(errorMessage, "Application Startup", 
            MessageBoxButton.OK, MessageBoxImage.Error);

        Shutdown();
    }
}

private bool CheckStartUpConditions(out string errorMessage)
{
    errorMessage = string.Empty;  

    if(...)
        errorMessage += "Please login to xxx. ";

    if(...)
        errorMessage += "Please install xxx.";

    if(string.IsNullOrEmpty(errorMessage))
        return true;
    else
        return false;
}
Run Code Online (Sandbox Code Playgroud)

在进入"POOF!"之前,消息框会短暂出现一段时间.它不等我单击"确定"或"X"按钮.我真的很难过为什么会这样,所以任何帮助都会非常感激.

我已经尝试将这个电话评论为Shutdown只是为了踢和笑,它仍然表现得一样.

此外,该应用程序也有一个SplashScreen,所以我不知道这是否会影响这一点.

编辑:如果有帮助,我添加了更多代码.消息框显示正确的错误消息.只是不会停留足够长的时间让用户阅读它.> :(

编辑第2部分:好的......我想我找到了罪魁祸首.:(我改变了我正在使用的图像上的构建操作,因为我从SplashScreen到我的飞溅到无,并且消息框现在将保留并等待用户输入.我不明白为什么SplashScreen与MessageBox一起拧紧.>: (

c# wpf messagebox

16
推荐指数
3
解决办法
7517
查看次数

WPF MessageBox不等待结果[WPF NotifyIcon]

我正在使用WPF NotifyIcon来创建系统托盘服务.当我显示一个消息框时,它会显示半秒钟然后立即消失而不等待输入.

之前发生过这种情况,通常的建议是使用接受Window参数的重载.但是,作为系统托盘服务,没有窗口可用作父级,并且null不会在其位置接受.

有没有办法让MessageBox等待用户输入自己创建一个自定义MessageBox窗口?

.net c# wpf messagebox notifyicon

7
推荐指数
2
解决办法
3231
查看次数

标签 统计

c# ×2

messagebox ×2

wpf ×2

.net ×1

notifyicon ×1