我正在尝试使用Navigation.PushAsync
转到我的Xamarin Forms应用程序中的新页面。我在与当前页面相同的文件夹中有一个名为InvMachineryItem.xaml
的页面。Xamarin - 无法找到类型或名称空间名称
在我目前的页面我有一个列表。点击列表时,新页面应该打开。
这里是我的代码:
using myCoolApp.Views; //folder with the pages in it
async void navigateView()
{
Page page = new InvMachineryItem();
await Navigation.PushAsync(page);
}
void machineList_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
navigateView();
//...more stuff
}
问题是我收到的错误:
The type or namespace name "InvMachineryItem' could not be found (are you missing a using directive or an assembly reference?)
我很困惑,因为他们是在同一个文件夹中,而我也实现using
声明。
有关其他方面,这里是InvMachineryItem.xaml.cs类
namespace myCoolApp.Views.Inventory
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class InvMachineryItem : ContentPage
{
List<ListTemplate> viewButtons = new List<ListTemplate>();
SessionData viewModel;
public InvMachineryItem()
{
InitializeComponent();
viewModel = ViewModelLocator.Session;
NavigationPage.SetHasNavigationBar(this, false);
viewButtons.Add(new ListTemplate("view.png", "View", true, true));
viewButtons.Add(new ListTemplate("edit.png", "Edit", true, true));
viewButtons.Add(new ListTemplate("AddMaintenance.png", "Add Maintenance", true, true));
}
}
}
你还可以分享InvMachineryItem的类吗?谢谢! – mindOfAi
当然,有一刻 –
InvMachineryItem在myCoolApp.Views.Inventory中,您应该将using语句添加到其他文件的停止处,或者将它们更改为使它们都在相同的命名空间中 – Jason