gpt4 book ai didi

c# - mahapps metro showMessageAsync 错误 : "Object reference not set to an instance of an object"

转载 作者:行者123 更新时间:2023-11-30 20:50:57 34 4
gpt4 key购买 nike

我有这个方法

    public async void setState(int state)
{
switch (state)
{
default:
await this.ShowMessageAsync("Title", "Message");
break;
}
}

我从 MetroWindow 的计算器调用它。但是我得到这个错误:

An exception of type 'System.NullReferenceException' occurred in MahApps.Metro.dll but was not handled in user code

Additional information: Object reference not set to an instance of an object.

在线

await this.ShowMessageAsync("Title", "Message");

我该如何解决这个问题?

最佳答案

ShowMessageAsync(...) 使用尚未构造的 overlayBox,因此您需要将调用移到构造函数之外。 https://github.com/MahApps/MahApps.Metro/blob/master/MahApps.Metro/Controls/MetroWindow.cs#L468

关于c# - mahapps metro showMessageAsync 错误 : "Object reference not set to an instance of an object",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22148988/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com