C#-覆盖OnFileActivated-没有合适的方法

时间:2020-07-30 04:25:47

标签: c# uwp overriding

遵循示例here.

此代码引发错误:

protected override void OnFileActivated(FileActivatedEventArgs args)
{
       // TODO: Handle file activation
       // The number of files received is args.Files.Size
       // The name of the first file is args.Files[0].Name
}

错误是:

'MainPage.OnFileActivated(FileActivatedEventArgs)': no suitable method found to override

为什么找不到此替代方法?我正在使用UWP。

1 个答案:

答案 0 :(得分:2)

如果您查看文档

https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.application.onfileactivated?view=winrt-19041

您将看到重写应该在应用程序类上,您没有提供代码,但看起来您试图在页面上重载它。