【发布时间】:2017-08-23 14:10:58
【问题描述】:
试图在 c++/cx XAML 中重现 this c# XAML 教程示例。 转到视频中的this exact 位置,看看我们为什么要添加全局变量。
这里我如何声明我的变量“someImportantValue”:
namespace NewMultiPages
{
ref class App sealed
{
protected:
virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override;
internal:
App();
static Platform::String ^someImportantValue;
private:
void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e);
void OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e);
};
}
这里是page2中的代码,我点击按钮转到page3:
void NewMultiPages::Page2::HyperlinkButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
App::someImportantValue = ValueTextBox->Text;
this->Frame->Navigate(Page3::typeid, ValueTextBox->Text);
}
编译时出现这个错误:
Erreur LNK2001 symbole externe non résolu "public: static class Platform::String ^ NewMultiPages::App::someImportantValue" (?someImportantValue@App@NewMultiPages@@2P$AAVString@Platform@@$AA) NewMultiPages C:\用户\lr\Documents\Visual Studio 2017\Projects\NewMultiPages\NewMultiPages\Page2.xaml.obj 1
【问题讨论】:
标签: xaml navigation c++-cx