所以我来自Windows窗体,我试图在Visual Studio 2017中为运行Windows IOT的覆盆子pi创建一个UWP(通用Windows程序)。我需要弄清楚如何用程序创建多个窗口,所以我按照微软的这个教程来开发:https://docs.microsoft.com/en-us/windows/uwp/design/basics/navigate-between-two-pages。理论上,它应该编译得很好,然而,它返回:
Error C2065 'Page2': undeclared identifier (page1.xaml.cpp)
Error C2653 'Page2': is not a class or namespace name (page1.xaml.cpp)
Error C2065 'Page1': undeclared identifier (page2.xaml.cpp)
Error C2065 'Page1': undeclared identifier NavApp1 (app.xaml.cpp)
Error C2653 'Page1': is not a class or namespace name (page2.xaml.cpp)
Error C2653 'Page1': is not a class or namespace name (app.xaml.cpp)
我的代码:(Page1.xaml.cpp):
#include "Page2.xaml.h" #include "pch.h" #include "Page1.xaml.h"
void NavApp1::Page1::HyperlinkButton_Click(Platform::Object^ sender,
Windows::UI::Xaml::RoutedEventArgs^ e)
{ this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(Page2::typeid)); }
我的代码:(Page2.xaml.cpp):
#include "Page1.xaml.h" #include "pch.h" #include "Page2.xaml.h"
void NavApp1::Page2::HyperlinkButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(Page1::typeid));}
答:我能够解决这个问题
#include "Page1.xaml.h"
#include "Page2.xaml.h"
在#include pch.h下的所有.cpp文件中