2014-09-13 31 views
0

我得到以下錯誤:Windows.Ui.Xaml.Controls.Primitives.ButtonBase無法顯式調用運算符或訪問

Windows.Ui.Xaml.Controls.Primitives.ButtonBase cannot explicitly call operator or 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

這是編譯時錯誤。而從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; 
+0

謝謝它工作得很好;)但後來我需要添加對象和事件參數,但我不知道..我 – Christos 2014-09-13 17:42:50