CS0123 C#无过载';HyperlinkButton单击';匹配委托';RoutedEventHandler&x27;

CS0123 C#无过载';HyperlinkButton单击';匹配委托';RoutedEventHandler&x27;,c#,xaml,navigation,delegates,C#,Xaml,Navigation,Delegates,Windows通用应用程序。我在这里找不到答案。我犯了一个错误CS0123 C#“HyperlinkButtonClick”没有重载匹配代理“RoutedEventHandler”。同样问题的大多数答案都告诉我们要更仔细地观察签名。或者使用更多的“global”,因为我已经将windows命名为namespace。但在我的情况下(我认为)情况是在其他方面。我只想从一页转到另一页。这看起来像是自动生成文件中的问题,但不应该如此。第二个页面位于同一命名空间中。请帮帮我:) 代码示例: MainPag

Windows通用应用程序。我在这里找不到答案。我犯了一个错误CS0123 C#“HyperlinkButtonClick”没有重载匹配代理“RoutedEventHandler”。同样问题的大多数答案都告诉我们要更仔细地观察签名。或者使用更多的“
global
”,因为我已经将windows命名为namespace。但在我的情况下(我认为)情况是在其他方面。我只想从一页转到另一页。这看起来像是自动生成文件中的问题,但不应该如此。第二个页面位于同一命名空间中。请帮帮我:)

代码示例:

MainPage.xaml

<Page
    x:Class="somepath.Windows.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:somepath.Windows"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <StackPanel x:Name="contentPanel" Margin="8,32,0,0">
           <HyperlinkButton x:Name="nameButton" Content="name" Click="HyperlinkButtonClick" HorizontalAlignment="Stretch"/>
        </StackPanel>
    </Grid>
</Page>
还有一个自动生成的文件

MainPage.g.cs

using Windows.UI.Xaml.Controls;

namespace somepath.Windows
{
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }

        private void HyperlinkButtonClick (object sender, System.EventArgs e)
        {
            this.Frame.Navigate (typeof (SecondPage));
        }
    }
}
       namespace somepath.Windows
    {
        partial class MainPage : 
            global::Windows.UI.Xaml.Controls.Page, 
            global::Windows.UI.Xaml.Markup.IComponentConnector,
            global::Windows.UI.Xaml.Markup.IComponentConnector2
        {
                      [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Windows.UI.Xaml.Build.Tasks"," 14.0.0.0")]
            [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
            public void Connect(int connectionId, object target)
            {
                switch(connectionId)
                {
                case 1:
                   .
                   .
                   .
                case 15:
                    {
                        this.nameButton = (global::Windows.UI.Xaml.Controls.HyperlinkButton)(target);
                        #line 25 "..\..\..\MainPage.xaml"


((global::Windows.UI.Xaml.Controls.HyperlinkButton)this.nameButton).Click += this.HyperlinkButtonClick;

                        #line default
                    }
                    break;
                default:
                    break;
                }
                this._contentLoaded = true;
            }

            [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Windows.UI.Xaml.Build.Tasks"," 14.0.0.0")]
            [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
            public global::Windows.UI.Xaml.Markup.IComponentConnector GetBindingConnector(int connectionId, object target)
            {
                global::Windows.UI.Xaml.Markup.IComponentConnector returnValue = null;
                return returnValue;
            }
        }
    }

MainPage.xaml.cs中的事件处理程序不正确。第二个参数的类型应为RoutedEventArgs,而不是System.EventArgs。

因此,请更改以下代码:

    private void HyperlinkButtonClick (object sender, System.EventArgs e)
    {
        this.Frame.Navigate (typeof (SecondPage));
    }
为此:

    private void HyperlinkButtonClick(object sender, RoutedEventArgs e)
    {
        this.Frame.Navigate (typeof (SecondPage));
    }