c# - visual studio 2010 中的 mahapps 对话框

标签 c# visual-studio-2010 mahapps.metro

我想在检索时显示带有用户友好消息的进度对话框 数据。我正在使用 visual studio 2010。我尝试使用此代码

/// <summary>
    /// Shows a progress message to the user.
    /// </summary>
    /// <param name="header">The header text for the dialog.</param>
    /// <param name="message">The message to be displayed in the dialog.</param>
    void ShowProgressMessage(string header, string message)
    {
        _isMessageDialogVisible = true;

        _controller = _metroWindow.ShowProgressAsync(header, message);
    }

    /// <summary>
    /// Closes a message dialog that is visible.
    /// </summary>
    void CloseProgressMessage()
    {
        if (_isMessageDialogVisible)
        {
            _isMessageDialogVisible = false;
            if (null != _controller)
            {
                var controller = _controller.Result;
                controller.CloseAsync();
            }
        }
    }

但它给出了一个错误:

22 09 2015 [9] DEBUG - OPGSpiral Error App.AppDispatcherUnhandledException --- System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.

在 MahApps.Metro.Controls.Dialogs.BaseMetroDialog.HandleTheme() 在 MahApps.Metro.Controls.Dialogs.BaseMetroDialog.Initialize() 在 MahApps.Metro.Controls.Dialogs.BaseMetroDialog..ctor(MetroWindow owningWindow,MetroDialogSettings 设置) 在 MahApps.Metro.Controls.Dialogs.ProgressDialog..ctor(MetroWindow parentWindow,MetroDialogSettings 设置) 在 MahApps.Metro.Controls.Dialogs.ProgressDialog..ctor(MetroWindow parentWindow) 在 MahApps.Metro.Controls.Dialogs.DialogManager.<>c__DisplayClass43.b__3b() --- 内部异常堆栈跟踪结束 --- 在 System.RuntimeMethodHandle.InvokeMethod(对象目标,对象 [] 参数,签名 sig, bool 构造函数) 在 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(对象 obj,对象 [] 参数,对象 [] 参数) 在 System.Delegate.DynamicInvokeImpl(Object[] args) 在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托(delegate)回调,对象参数,Int32 numArgs) 在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源、委托(delegate)回调、对象参数、Int32 numArgs、委托(delegate) catchHandler) 22 09 2015 [9] DEBUG - OPGSpiral Error App.AppDispatcherUnhandledException --- System.Reflection.TargetInvocationException:调用目标抛出异常。 ---> System.NullReferenceException:对象引用未设置为对象的实例。 在 MahApps.Metro.Controls.Dialogs.BaseMetroDialog.HandleTheme() 在 MahApps.Metro.Controls.Dialogs.BaseMetroDialog.Initialize() 在 MahApps.Metro.Controls.Dialogs.BaseMetroDialog..ctor(MetroWindow owningWindow,MetroDialogSettings 设置) 在 MahApps.Metro.Controls.Dialogs.ProgressDialog..ctor(MetroWindow parentWindow,MetroDialogSettings 设置) 在 MahApps.Metro.Controls.Dialogs.ProgressDialog..ctor(MetroWindow parentWindow) 在 MahApps.Metro.Controls.Dialogs.DialogManager.<>c__DisplayClass43.b__3b() --- 内部异常堆栈跟踪结束 --- 在 System.RuntimeMethodHandle.InvokeMethod(对象目标,对象 [] 参数,签名 sig, bool 构造函数) 在 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(对象 obj,对象 [] 参数,对象 [] 参数) 在 System.Delegate.DynamicInvokeImpl(Object[] args) 在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托(delegate)回调,对象参数,Int32 numArgs) 在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源、委托(delegate)回调、对象参数、Int32 numArgs、委托(delegate) catchHandler)

最佳答案

这应该在 1.2.2 中修复,可通过 NuGet 获得.

关于c# - visual studio 2010 中的 mahapps 对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32722386/

相关文章:

wpf - Mahapps 弹出窗口未与 caliburn.micro 一起出现

c# - Visual Studio 格式文档——如何用 C# 编写

c# - 如何在单击按钮时获取 ListView 行的索引

c# - 带有从文件加载的客户端证书的 HttpClient

c++ - VS2010 缺少 ws2_32.lib。怎么办?

c++ - 未解析的外部符号 __report_rangecheckfailure

wpf - 在MahApp应用程序中设置图标颜色

c# - 正则表达式替换 Windows 换行符

visual-studio-2010 - WCF Web.config - 无法读取配置节 'system.webserver',因为它缺少节声明

wpf - 防止飞出时焦点切换到主窗体 IsOpen=false;