我有这个代码:
async private void InformUserOfRenameOption(string platypusName)
{
CoreWindowDialog cwd = new CoreWindowDialog(String.Format(
"This platypus has been given the default name {0}. Do you want to change it?", platypusName));
cwd.Commands.Add(new UICommand { Label = "Yes", Id = 0 });
cwd.Commands.Add(new UICommand { Label = "No", Id = 1 });
cwd.Commands.Add(new UICommand { Label = "Cancel", Id = 2 });
cwd.CancelCommandIndex = 2;
IUICommand cmd = await cwd.ShowAsync();
//if (cmd.Id == 0) <= 'Operator '==' cannot be applied to operands of type 'object' and 'int'
if (Convert.ToInt32(cmd.Id) == 0)
{
appbarbtnRenamePlatypus.Tapped();
}
}
...但是我尝试以编程方式点击 AppBarButton 失败,并出现编译时错误:“事件 'Windows.UI.Xaml.UIElement.Tapped' 只能出现在 += 或 -= 的左侧”
那么我如何以编程方式点击按钮,或者更具体地说,让它的 Button.Flyout Flyout 飞出?