visual studio 2010中的对话框
本文关键字:对话框 2010 studio visual | 更新日期: 2023-09-27 18:14:03
我想显示一个进度对话框与用户友好的消息,而我检索数据。我使用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 . .(MetroWindow owningWindow, MetroDialogSettings设置)在MahApps.Metro.Controls.Dialogs.ProgressDialog . .(MetroWindow parentwwindow, MetroDialogSettings设置)在MahApps.Metro.Controls.Dialogs.ProgressDialog . .男星(MetroWindow parentWindow)在MahApps.Metro.Controls.Dialogs.DialogManager灵活;> c__DisplayClass43.b__3b ()——内部异常堆栈跟踪结束——在System.RuntimeMethodHandle。调用方法(对象目标,对象[]参数,签名签名,布尔构造函数)在System.Reflection.RuntimeMethodInfo。UnsafeInvokeInternal(对象obj,对象[]参数,对象[]参数)在System.Delegate。DynamicInvokeImpl (Object[]参数)在System.Windows.Threading.ExceptionWrapper。InternalRealCall(Delegate callback, Object args, Int32 numArgs)在System.Windows.Threading.ExceptionWrapper。TryCatchWhen(对象源,委托回调,对象参数,Int32 numArgs,委托catchHandler)22 09 2015 [9] DEBUG - opg螺旋错误App.AppDispatcherUnhandledException——System.Reflection.TargetInvocationException:异常已经被调用的目标抛出。——>系统。NullReferenceException:对象引用没有设置为对象的实例。在MahApps.Metro.Controls.Dialogs.BaseMetroDialog.HandleTheme ()在MahApps.Metro.Controls.Dialogs.BaseMetroDialog.Initialize ()在MahApps.Metro.Controls.Dialogs.BaseMetroDialog . .(MetroWindow owningWindow, MetroDialogSettings设置)在MahApps.Metro.Controls.Dialogs.ProgressDialog . .(MetroWindow parentwwindow, MetroDialogSettings设置)在MahApps.Metro.Controls.Dialogs.ProgressDialog . .男星(MetroWindow parentWindow)在MahApps.Metro.Controls.Dialogs.DialogManager灵活;> c__DisplayClass43.b__3b ()——内部异常堆栈跟踪结束——在System.RuntimeMethodHandle。调用方法(对象目标,对象[]参数,签名签名,布尔构造函数)在System.Reflection.RuntimeMethodInfo。UnsafeInvokeInternal(对象obj,对象[]参数,对象[]参数)在System.Delegate。DynamicInvokeImpl (Object[]参数)在System.Windows.Threading.ExceptionWrapper。InternalRealCall(Delegate callback, Object args, Int32 numArgs)在System.Windows.Threading.ExceptionWrapper。TryCatchWhen(对象源,委托回调,对象args, Int32 numArgs,委托catchHandler)
这应该在1.2.2中修复,它可以通过NuGet获得。