我在弹出菜单中遇到了一个奇怪的问题(这不是我第一次在我的代码中使用,所以我不明白为什么会这样)。
A first chance exception of type 'System.ArgumentException' occurred
这是显示PopupMenu的代码:
PopupMenu p = new PopupMenu();
p.Commands.Add(new UICommand { Label = "Delete gear", Id = 0 });
p.Commands.Add(new UICommand { Label = "-", Id = 1 });
if (index != 0) // If first elem, don't show this part
{
p.Commands.Add(new UICommand { Label = "Bring to top", Id = 2 });
p.Commands.Add(new UICommand { Label = "Bring up", Id = 3 });
}
if (index != GearTree[0].GearGroup.Count - 1) // If last elem, don't show this part
{
p.Commands.Add(new UICommand { Label = "Bring down", Id = 4 });
p.Commands.Add(new UICommand { Label = "Bring to bottom", Id = 5 });
}
// TODO: here happens the ERROR, posibly in new Point(0,0) part
IUICommand selection = await p.ShowAsync(new Point(0, 0));