我打电话给Guide.BeginShowMessageBox有问题
这是我的代码:
public object FuelTypeIndex { get; private set; }
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
var messageCommands = new Dictionary<string, Action>()
{
{ "Diesel", () => {FuelTypeIndex = 0;}},
{ "Petrol", () => {FuelTypeIndex = 1;}},
{ "Other", () => {FuelTypeIndex = 2;}},
};
var result = Guide.BeginShowMessageBox("Title", "Message", messageCommands.Keys, 0, MessageBoxIcon.Warning, null, null);
result.AsyncWaitHandle.WaitOne();
int? choice = Guide.EndShowMessageBox(result);
if (choice.HasValue)
messageCommands.ElementAt(choice.Value).Value.Invoke();
}我得到以下例外:
“System.ArgumentException”类型的异常发生在Microsoft.Xna.Framework.GamerServices.ni.dll中,但未在用户代码中处理 附加信息:参数无效。它必须包含1到2个字符串。字符串不能为空或空,且长度必须小于256个字符。
通过调试,我将问题定位为messageCommands.Keys,因为如果我用静态数组调用函数,它就能正常工作。
那我做错什么了?
发布于 2015-12-22 17:44:29
问题是调用Guide.BeginShowMessageBox时请求的按钮数量。根据文档,在Windows上,最大的按钮数是两个。
https://stackoverflow.com/questions/34417289
复制相似问题