【问题标题】:xamarin Essentials: No overload for > 'OnMainDisplayInfoChanged' matches delegate > 'EventHandler<DisplayInfoChangedEventArgs>'xamarin Essentials:> 'OnMainDisplayInfoChanged' 没有重载匹配委托 > 'EventHandler<DisplayInfoChangedEventArgs>'
【发布时间】:2019-02-11 07:55:36
【问题描述】:

我正在使用我的代码关注 Xamarin 示例:

    public App()
    {
        InitializeComponent();
        DeviceDisplay.MainDisplayInfoChanged += OnMainDisplayInfoChanged;
    }

    void OnMainDisplayInfoChanged(DisplayInfoChangedEventArgs e)
    {
        var displayInfo = e.DisplayInfo;
    }

据我所知,这与此示例中的相同:

https://docs.microsoft.com/en-us/xamarin/essentials/device-display?context=xamarin%2Fios&tabs=uwp

但它给了我错误信息:

App.xaml.cs(13,13):错误 CS0123:没有过载 'OnMainDisplayInfoChanged' 匹配委托 '事件处理程序' (CS0123)

谁能帮我解释一下这个错误消息的含义,如果有办法解决这个问题,请告诉我?

【问题讨论】:

    标签: c# xamarin xamarin.forms xamarin.essentials


    【解决方案1】:

    出现此错误是因为您缺少第一个 paramobject sender。尝试传递完整的方法签名。

    private void OnMainDisplayInfoChanged(object sender, DisplayInfoChangedEventArgs e)
    {
       var displayInfo = e.DisplayInfo;
    }
    

    【讨论】:

    • 谢谢,看起来 xamarin 文档也有这个错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多