Visual Studio 2010中的mahapps对话框

时间:2015-09-22 16:44:44

标签: 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.

at 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。&lt;&gt; c__DisplayClass43.b__3b()    ---内部异常堆栈跟踪结束---    at System.RuntimeMethodHandle.InvokeMethod(Object target,Object [] arguments,Signature sig,Boolean constructor)    at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,Object [] parameters,Object [] arguments)    在System.Delegate.DynamicInvokeImpl(Object [] args)    在System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调,对象args,Int32 numArgs)    在System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source,Delegate callback,Object args,Int32 numArgs,Delegate catchHandler) 22 09 2015 [9]调试 - OPGSpiral错误App.AppDispatcherUnhandledException --- System.Reflection.TargetInvocationException:调用目标抛出了异常。 ---&GT; 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。&lt;&gt; c__DisplayClass43.b__3b()    ---内部异常堆栈跟踪结束---    at System.RuntimeMethodHandle.InvokeMethod(Object target,Object [] arguments,Signature sig,Boolean constructor)    at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,Object [] parameters,Object [] arguments)    在System.Delegate.DynamicInvokeImpl(Object [] args)    在System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调,对象args,Int32 numArgs)    at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source,Delegate callback,Object args,Int32 numArgs,Delegate catchHandler)

1 个答案:

答案 0 :(得分:0)

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