So I came from Windows forms and I'm attempting to create a UWP (Universal Windows Program) in Visual Studio 2017 for my raspberry pi running Windows IOT. I need to figure out how to create multiple windows with a program, so I followed this tutorial by Microsoft to a tee: https://learn.microsoft.com/en-us/windows/uwp/design/basics/navigate-between-two-pages. Theoretically, it should compile just fine and all, however, it returns:
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)
My code: (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)); }
My code: (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));}
Answer: I was able to fix this issue by putting
#include "Page1.xaml.h"
#include "Page2.xaml.h"
On all .cpp files under #include pch.h