Items of note:
-
This application is packaged to simplify deployment. In particular, we use the
uap:Protocol
element in thePackage.appxmanifest
to do the work of registering a protocol handler upon install and unregistering it upon uninstall. -
Both the
MainWindow.xaml.cs and
BookViewer.xaml.csfiles use a COM interop helper to obtain the
ApplicationViewTitleBar object. The colors set on this object are shown in the tab. -
Both the
MainWindow.xaml.cs
andBookViewer.xaml.cs
create aUserActivity
when 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 callCreateSessionForWindow
so 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
OnUserActivityRequested
method in theBookViewer.xaml.cs
file 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_Startup
method inApp.xaml.cs
first parses the URI to determine which window to create, and theBookViewer
constructor parses the query portion of the URI to extract the book and optional scroll position. Restoring the scroll position is done in theWindow_SourceInitialized
method. -
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
BookViewer
constructor remembers the desired grouping behavior and applies it in theWindow_SourceInitialized
method. -
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
DoShellExecute
method saves this grouping behavior to theGroupingPreferenceSite
so that when theShellExecuteEx
function asks if the app wishes to customize the grouping behavior, theGroupingPreferencesSite
can do so.