2017-03-24 14 views
-1

私のアプリに「終了」ボタンを追加します。私はこのような何かを書く場合
:私はUWP C++アプリケーションをプログラムで終了または閉じるにはどうすればいいですか?

void LibraryUWP::MainPage::ExitEvent(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) 
{ 
    Application::Exit(); 
} 

を実行する場合は、私が持っている

1>...\mainpage.xaml.cpp(32): error C3867: 'Windows::UI::Xaml::Application::Exit': non-standard syntax; use '&' to create a pointer to member

void LibraryUWP::MainPage::ExitEvent(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) 
{ 
    Application::Exit; 
} 

私はエラーを持っている

1>...\mainpage.xaml.cpp(32): error C2352: 'Windows::UI::Xaml::Application::Exit': illegal call of non-static member function

そして、もし私はこれを実行する:

void LibraryUWP::MainPage::ExitEvent(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) 
{ 
    Application::Current::Exit(); 
} 

私はエラーを持っている:

1>...\mainpage.xaml.cpp(32): error C2039: 'Exit': is not a member of 'Windows::UI::Xaml::Application::Current'
1>...\mainpage.xaml.cpp(32): error C3861: 'Exit': identifier not found

は、私が最初に&第二の変形が動作しないことができることを、理解しています。しかし、第三はどうですか?または、他の何か?

MSのVisual Studio 2015のアップデートのWindows 10.10240プラットフォーム

P.S. 3. 私が最後のブレイカーなしで3番目の変種を実行すると、同じエラーが発生します。私にはそのような方法がないことがわかります。

答えて

4
これにあなたのコードを変更

void MyApp::MainPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) 
{ 
    Application::Current->Exit(); 
} 

おかげで、

ステファンウィック - Windowsの開発プラットフォーム

+0

大感謝をあなたに – AJIOB

関連する問題