【发布时间】:2016-12-17 06:10:04
【问题描述】:
我有一个 ContentView,用作我页面上的共享代码。它包含导航链接等。在 ContentView 中,我试图访问我的 App 类中具有以下签名的方法:
public void ClearNavigationAndGoToPage(Page pobj_Page)
{
MainPage = new NavigationPage(pobj_Page);
}
但是,当我在 ContentView 中使用以下代码行时
App.ClearNavigationAndGoToPage(new nearbyplaces());
我收到以下错误消息:
非静态字段、方法或属性“App.ClearNavigationAndGoToPage(Page)”需要对象引用
我可以从 ContentPages 访问该方法,但不能从 ContentViews 访问。有什么建议吗?
【问题讨论】:
-
您尝试从静态调用的方法是什么?
-
我想感谢 Esteban,因为我没有将方法标记为静态,因此出现问题。
标签: c# xamarin.forms