1 //*********************************************************
3 // Copyright (c) Microsoft. All rights reserved.
4 // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
5 // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
6 // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
7 // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 //*********************************************************
13 #include <collection.h>
20 /// Typical implementation of Page that provides several important conveniences:
21 /// <list type="bullet">
23 /// <description>Application view state to visual state mapping</description>
26 /// <description>GoBack, GoForward, and GoHome event handlers</description>
29 /// <description>Mouse and keyboard shortcuts for navigation</description>
32 /// <description>State management for navigation and process lifetime management</description>
35 /// <description>A default view model</description>
39 [Windows::Foundation::Metadata::WebHostHidden]
40 public ref class LayoutAwarePage : Windows::UI::Xaml::Controls::Page
46 void StartLayoutUpdates(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
47 void StopLayoutUpdates(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
48 void InvalidateVisualState();
49 static property Windows::UI::Xaml::DependencyProperty^ DefaultViewModelProperty
51 Windows::UI::Xaml::DependencyProperty^ get();
53 property Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::Object^>^ DefaultViewModel
55 Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::Object^>^ get();
56 void set(Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::Object^>^ value);
60 virtual void GoHome(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
61 virtual void GoBack(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
62 virtual void GoForward(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
63 virtual Platform::String^ DetermineVisualState(Windows::UI::ViewManagement::ApplicationViewState viewState);
64 virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
65 virtual void OnNavigatedFrom(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
66 virtual void LoadState(Platform::Object^ navigationParameter,
67 Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ pageState);
68 virtual void SaveState(Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ pageState);
71 Platform::String^ _pageKey;
72 bool _navigationShortcutsRegistered;
73 Platform::Collections::Map<Platform::String^, Platform::Object^>^ _defaultViewModel;
74 Windows::Foundation::EventRegistrationToken _windowSizeEventToken,
75 _acceleratorKeyEventToken, _pointerPressedEventToken;
76 Platform::Collections::Vector<Windows::UI::Xaml::Controls::Control^>^ _layoutAwareControls;
77 void WindowSizeChanged(Platform::Object^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ e);
78 void OnLoaded(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
79 void OnUnloaded(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
81 void CoreDispatcher_AcceleratorKeyActivated(Windows::UI::Core::CoreDispatcher^ sender,
82 Windows::UI::Core::AcceleratorKeyEventArgs^ args);
83 void CoreWindow_PointerPressed(Windows::UI::Core::CoreWindow^ sender,
84 Windows::UI::Core::PointerEventArgs^ args);
85 LayoutAwarePage^ _this; // Strong reference to self, cleaned up in OnUnload