我正在嘗試使用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