我收到以下错误:
Windows.Ui.Xaml.Controls.Primitives.ButtonBase无法显式调用operator或accessor
错误发生在以下代码中:
case 11:
{
ButtonBase buttonBase2 = (ButtonBase)target;
WindowsRuntimeMarshal.AddEventHandler<RoutedEventHandler>(new Func<RoutedEventHandler, EventRegistrationToken>(buttonBase2, ButtonBase.add_Click), new Action<EventRegistrationToken>(buttonBase2, ButtonBase.remove_Click), new RoutedEventHandler(this.RemoveTrack));
break;
}
答案 0 :(得分:0)
这是编译时错误。来自MSDN WindowsRuntimeMarshal.AddEventHandler Method:
This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.
如果要向Click事件添加/删除事件处理程序,请使用+=
and -=
operators
buttonBase2.Click += this.RemoveTrack;
和
buttonBase2.Click -= this.RemoveTrack;