WP7 — NavigationService.Navigate is complaining that it is not receiving an object reference . . . but why?

后端 未结 2 992
[愿得一人]
[愿得一人] 2021-02-05 18:45

WP7 newb question here.

I have the following code:

public class KeyboardHandler : INotifyPropertyChanged
{
    // lots of methods here

    public void F         


        
2条回答
  •  青春惊慌失措
    2021-02-05 19:14

    NavigationService is the name of a property in the PhoneApplicationPage class, but it is also the name of the class.

    When you call the NavigationService.Navigate() method from a page, you use the object from the base class. But in your case, you don't have an object with this name, so the compiler try to access the NavigationService class, and make a call like if Navigate was a static method.

    But it is not static, this is why you receive this error : you must use an instance of NavigationService

提交回复
热议问题