Items of note:
-
This application is packaged to simplify deployment. In particular, we use the
uap:Protocolelement in thePackage.appxmanifestto do the work of registering a protocol handler upon install and unregistering it upon uninstall. -
Both the
MainWindow.xaml.cs andBookViewer.xaml.csfiles use a COM interop helper to obtain theApplicationViewTitleBar object. The colors set on this object are shown in the tab. -
Both the
MainWindow.xaml.csandBookViewer.xaml.cscreate aUserActivitywhen the user visits the page. Applications can choose any string for theiractivityId. For simplicity, this sample app uses the URI path and query as theactivityId. Observe that the code to create the activity is the same as in the UWP app. -
The sample uses the AdaptiveCards NuGet package to generate adaptive card JSON. You are welcome to use any JSON library (or no library at all!) to generate your adaptive cards.
-
Instead of
CreateSession, Win32 apps must callCreateSessionForWindowso that the system can associate the activity with the correct window. -
The sample checks whether functionality new to version 1803 and to Windows Insider builds is present in the system.
-
The
OnUserActivityRequestedmethod in theBookViewer.xaml.csfile generates a user activity which represents the current scroll position of the document. That position is is encoded in the URI, and when the app is activated with that URI, theApplication_Startupmethod inApp.xaml.csfirst parses the URI to determine which window to create, and theBookViewerconstructor parses the query portion of the URI to extract the book and optional scroll position. Restoring the scroll position is done in theWindow_SourceInitializedmethod. -
Right-clicking a book from the main page brings up a menu that gives the option of opening the book in a new tab or in a new window. The
BookViewerconstructor remembers the desired grouping behavior and applies it in theWindow_SourceInitializedmethod. -
Right-clicking the word "Library" on the the main page brings up a menu that gives the option of opening Notepad in a new tab or in a new window. The
DoShellExecutemethod saves this grouping behavior to theGroupingPreferenceSiteso that when theShellExecuteExfunction asks if the app wishes to customize the grouping behavior, theGroupingPreferencesSitecan do so.