0

I am following a Xamarin Example with my code:

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

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

As far as I can see this is just the same as in this example:

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

But it is giving me the error message:

App.xaml.cs(13,13): Error CS0123: No overload for 'OnMainDisplayInfoChanged' matches delegate 'EventHandler' (CS0123)

Can anyone help explain to me what this error message means and let me know if there is a way for me to fix this?

Alan2
  • 23,493
  • 79
  • 256
  • 450

1 Answers1

3

This error is coming because you missing first param that is object sender. Try to pass full method signature.

private void OnMainDisplayInfoChanged(object sender, DisplayInfoChangedEventArgs e)
{
   var displayInfo = e.DisplayInfo;
}
R15
  • 13,982
  • 14
  • 97
  • 173