<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Universal Windows App Model</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/universal-windows-app-model/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/universal-windows-app-model/feed.xml</link>
    <description>The Windows App Model team blog for the latest public updates, technical articles and success stories.</description>
    <lastBuildDate>Tue, 16 Apr 2019 05:33:34 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Create Secondary Tiles from your Desktop Application</title>
      <link>https://docs.microsoft.com/archive/blogs/universal-windows-app-model/create-secondary-tiles-from-your-desktop-application</link>
      <pubDate>Thu, 25 May 2017 07:41:07 GMT</pubDate>
      <dc:creator><![CDATA[Vladimir Postel]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/universal-windows-app-model/?p=345</guid>
      <description><![CDATA[Starting from the Insider  Preview Build 16199 you can create SecondaryTiles directly from your...]]></description>
      <content:encoded><![CDATA[Starting from the Insider  <a href="https://blogs.windows.com/windowsexperience/2017/05/17/announcing-windows-10-insider-preview-build-16199-pc-build-15215-mobile/#bDqf2Ah3Gd7FM66g.97">Preview Build 16199</a> you can create SecondaryTiles directly from your desktop application by leveraging the <a href="https://developer.microsoft.com/en-us/windows/bridges/desktop">Desktop Bridge</a>.

A secondary tile provides a consistent, efficient way for users to directly access specific areas within a packaged app from the Start screen. Although a user chooses whether or not to "pin" a secondary tile to the Start screen, the pinnable areas in an app are determined by the developer.
Adding  <a href="https://msdn.microsoft.com/en-us/library/windows/apps/hh465398.aspx">a Secondary tile</a> from your WPF or Winforms is very similar to a pure UWP application, however there are few things to remember;
If you have a Win32 desktop application or a desktop application you need to specify your main window handle (HWND) in the API. The <strong>SecondaryTile</strong> displays a modal dialog to the user to get a confirmation from the user. If a desktop application does not configure the <strong>SecondaryTile</strong> object to specify the owner window for modal dialogs, this object will return inaccurate data or errors.

<img src="https://msdnshared.blob.core.windows.net/media/2017/05/SecondaryTile2-e1495665153576.png" alt="SecondaryTile" />

To configure a <strong>SecondaryTile</strong> object in a desktop application that uses the Desktop Bridge, follow these steps;


1. Do one of the following to enable your app to access the <a href="https://msdn.microsoft.com/library/windows/desktop/hh706981.aspx">IInitializeWithWindow</a> interface:
o  If your application is written in a managed language such as C# or Visual Basic, declare the <strong>IInitializeWithWindow</strong> interface in your app's code with the <a href="https://msdn.microsoft.com/library/system.runtime.interopservices.comimportattribute.aspx">ComImport</a> attribute as shown in the following C# example. This example assumes that your code file has a using statement for the <strong>System.Runtime.InteropServices</strong> namespace.

<div class="tabs">
<div title="C#">
<pre class="brush:csharp;">
[ComImport]
[Guid("3E68D4BD-7135-4D10-8018-9FB6D9F33FA1")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IInitializeWithWindow
{
  void Initialize(IntPtr hwnd);
}
</pre>
</div>
</div>

o   If your application is written in C++, add a reference to the shobjidl.h header file in your code. This header file contains the declaration of the <strong>IInitializeWithWindow</strong> interface.


2.  Create the secondary tile (it is the same code you will write in UWP);

<div class="tabs">
<div title="C#">
<pre class="brush:csharp;">
Uri square150x150Logo = new Uri("ms-appx:///Assets/square150x150Tile-sdk.png");
SecondaryTile tile = new SecondaryTile("SecondaryTileId" + PhotoListBox.SelectedIndex,
                                                            displayName,
                                                            tileActivationArguments,
                                                            square150x150Logo,
                                                            TileSize.Default);
</pre>
</div>
</div>



3.  Cast the object to an <a href="https://msdn.microsoft.com/library/windows/desktop/hh706981.aspx">IInitializeWithWindow</a> object. Then, call the <a href="https://msdn.microsoft.com/library/windows/desktop/hh706982.aspx">IInitializeWithWindow.Initialize</a>  method, and pass the handle of the window that you want to be the owner for the  modal dialog. The following C# example shows how to pass the handle of your app's main window to the method.

<div class="tabs">
<div title="C#">
<pre class="brush:csharp;">
IInitializeWithWindow initWindow = (IInitializeWithWindow)(object)tile;
initWindow.Initialize(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle);
tile.RequestCreateAsync();
</pre>
</div>
</div>

The full sample is available on GitHub, <a href="https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/SecondaryTileSample">here</a>.
To learn more about Secondary tiles and the Desktop Bridge, check out the resources below;

<h3>Resources</h3><ul>
<li><a title="Secondary tiles" href="https://msdn.microsoft.com/en-us/library/windows/apps/hh465372.aspx">Secondary tiles</a></li>
<li><a href="https://developer.microsoft.com/en-us/windows/bridges/desktop" target="_blank">Desktop Bridge</a></li>
<li><a href="https://github.com/Microsoft/DesktopBridgeToUWP-Samples" target="_blank">Samples</a></li>
</ul>

&nbsp;

Any questions? Leave them in the comments!

Enjoy! 
Vladimir Postel, Program Manager – Windows Developer Platform
]]></content:encoded>
    </item>
    <item>
      <title>Desktop Bridge: Creators Update</title>
      <link>https://docs.microsoft.com/archive/blogs/universal-windows-app-model/desktop-bridge-creators-update</link>
      <pubDate>Wed, 15 Mar 2017 08:14:01 GMT</pubDate>
      <dc:creator><![CDATA[Arian Ghotbi]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/universal-windows-app-model/?p=285</guid>
      <description><![CDATA[Overview
The creators update is packed with new features for app developers and end users.

These...]]></description>
      <content:encoded><![CDATA[<h1>Overview</h1>
The creators update is packed with new features for app developers and end users.

These features are designed to delight the developers who are in turn enabled to delight their end users as well as to provide a rich experience.
<h1>User Transition &amp; Data Migration</h1>
Users will be encouraged to download the store version of their desktop apps. If the user already has the previous desktop version of the app, the transition experience should be as seamless as possible.

As a result, the Creators Update will provide the ability to provide this smooth transition along with some best practices for app developers to follow.

<strong>For a detailed blog post on this topic with code samples</strong>, please see <a target="_blank" href="https://blogs.windows.com/buildingapps/2017/03/10/desktop-bridge-smooth-user-transition-data-migration/">this blog post</a>.
<h3>User Transition: Taskbar Pins &amp; Start Tiles</h3>
Many users typically pin their favorite or most used apps to the taskbar pin or the start menu. This enables them to access the app much faster.

With the Creators Update, app developers can re-route the taskbar pins and the start tile shortcuts to point to the store version of the desktop app.
<h3>User Transition: File type associations &amp; protocol handlers</h3>
The user may choose their favorite app to be the default app for a given file type or protocol. With the Creators Update, the developers can also transition the user's choice to use the store version of the same app.
<h3>Data Migration</h3>
As best practice, it is recommended for developers to attempt to migrate previous user data from the desktop app, upon first launch of the store version of the same app.

This will delight the users, so they can pick up where they left off.
<h3>User Transition: Uninstall previous desktop app</h3>
As best practice, it is recommended for developers to offer uninstallation of the previous desktop app upon first launch of the store version of the app. This will help in avoiding user confusion and potential user data corruption.

Keep in mind that the user can refuse the uninstallation of the previous desktop app, so the previous and store version of the app may end up running side-by-side. It is up to the app developer to decide whether or not to block the launch of the store version of the app, until the previous desktop app is uninstalled.
<h1>Windows Explorer delight: previews, thumbnails, detailed properties, and grouping by kind</h1>
&nbsp;

Another focus of the Creators Update release was on user delight.

Store version of desktop apps can now take advantage of Windows Explorer delighters to attract users to engage with their apps more.
<h2>Preview Handler</h2>
Preview handlers are called when an item is selected to show a lightweight, rich, read-only preview of the file's contents in the view's reading pane. This is done without launching the file's associated application.

<strong>XML sample:</strong>
<div class="tabs">
<div title="xml">
<pre class="brush:xml; highlight: [7]">&lt;Extensions&gt;
   &lt;Extension Category="windows.fileTypeAssociation"&gt;
      &lt;FileTypeAssociation Name="Foo"&gt;
         &lt;SupportedFileTypes&gt;
            &lt;FileType&gt;.bar&lt;/FileType&gt;
         &lt;/SupportedFileTypes&gt;
         &lt;DesktopPreviewHandler Clsid="20000000-0000-0000-0000-000000000001" /&gt;
      &lt;/FileTypeAssociation&gt;
   &lt;/Extension&gt;
&lt;/Extensions&gt;
</pre>
</div>
</div>
<img width="918" height="351" class="alignnone size-full wp-image-315" alt="thumbnail-preview" src="https://msdnshared.blob.core.windows.net/media/2017/03/Thumbnail-Preview.png" />
<h2>Thumbnail Handler</h2>
In Windows Explorer, thumbnails can provide a read-only view inside the file, when the viewing is set to medium icons or higher.

<strong>XML sample:</strong>
<div class="tabs">
<div title="xml">
<pre class="brush:xml; highlight: [7]">&lt;Extensions&gt;
   &lt;Extension Category="windows.fileTypeAssociation"&gt;
      &lt;FileTypeAssociation Name="Foo"&gt;
         &lt;SupportedFileTypes&gt;
            &lt;FileType&gt;.bar&lt;/FileType&gt;
         &lt;/SupportedFileTypes&gt;
         &lt;ThumbnailHandler Clsid="20000000-0000-0000-0000-000000000001" /&gt;
      &lt;/FileTypeAssociation&gt;
   &lt;/Extension&gt;
&lt;/Extensions&gt;
</pre>
</div>
</div>
<h2>Property Handler</h2>
Microsoft Windows Search uses property handlers to extract the values of properties from items and uses the property system schema to determine how a specific property should be indexed.

In addition, property handlers can be used to provide more details about a certain file in the properties dialog or in the details pane.

<img width="453" height="611" class="alignnone size-full wp-image-305" alt="property" src="https://msdnshared.blob.core.windows.net/media/2017/03/Property.png" />

<strong>XML sample:</strong>
<div class="tabs">
<div title="xml">
<pre class="brush:xml; highlight: [7]">&lt;Extensions&gt;
   &lt;Extension Category="windows.fileTypeAssociation"&gt;
      &lt;FileTypeAssociation Name="Foo"&gt;
         &lt;SupportedFileTypes&gt;
            &lt;FileType&gt;.bar&lt;/FileType&gt;
         &lt;/SupportedFileTypes&gt;
         &lt;DesktopPropertyHandler Clsid="20000000-0000-0000-0000-000000000001" /&gt;
      &lt;/FileTypeAssociation&gt;
   &lt;/Extension&gt;
&lt;/Extensions&gt;</pre>
</div>
</div>
<h2>Grouping files by their 'kind'</h2>
Developers can specify what 'kind' their file types are, which will enable the end users to group their files by their kind in Windows Explorer.

<img width="2202" height="939" class="alignnone size-full wp-image-295" alt="kind" src="https://msdnshared.blob.core.windows.net/media/2017/03/Kind.png" />

<strong>XML sample:</strong>
<div class="tabs">
<div title="xml">
<pre class="brush:xml; highlight: [7,8,9,10,11]">&lt;uap:Extension Category="windows.fileTypeAssociation"&gt;
   &lt;uap:FileTypeAssociation Name="scoobydoo"&gt;
      &lt;uap:SupportedFileTypes&gt;
         &lt;uap:FileType&gt;.m4a&lt;/uap:FileType&gt;
         &lt;uap:FileType&gt;.mta&lt;/uap:FileType&gt;
      &lt;/uap:SupportedFileTypes&gt;
      &lt;rescap:KindMap&gt;
         &lt;rescap:Kind value="Item" /&gt;
         &lt;rescap:Kind value="Communications" /&gt;
         &lt;rescap:Kind value="Task" /&gt;
      &lt;/rescap:KindMap&gt;
   &lt;/uap:FileTypeAssociation&gt;
&lt;/uap:Extension&gt;</pre>
</div>
</div>
<h1>Support for custom fonts installation by apps</h1>
Microsoft Windows Store apps can share their custom fonts with other Windows applications. This is done by making a few simple edits to the application manifest.

<strong>XML sample:</strong>
<div class="tabs">
<div title="xml">
<pre class="brush:xml;">&lt;Extensions&gt;
   &lt;uap4:Extension Category="windows.sharedFonts"&gt;
      &lt;uap4:SharedFonts&gt;
         &lt;uap4:Font File="Fonts\JustRealize.ttf" /&gt;
         &lt;uap4:Font File="Fonts\JustRealizeBold.ttf" /&gt;
      &lt;/uap4:SharedFonts&gt;
   &lt;/uap4:Extension&gt;
&lt;/Extensions&gt;</pre>
</div>
</div>
<h1>Public out-of-process COM server support, aka Packaged COM</h1>
Developers can now add support for out-of-process COM and OLE extensions support for store version of desktop apps.  This technology is referred to as Packaged COM.  Historically, desktop apps would create COM extensions that other applications could use.  However, in the Windows 10 Anniversary Update release of the Desktop Bridge, an application cannot expose its COM extension points as all registry entries are in its private hive and not exposed publicly to the system.  Packaged COM provides a mechanism for COM &amp; OLE entries to be declared in the manifest while the underlying subsystem handles the activation of the objects while still providing no-impact install behavior. This is a large extension and will be the focus of a future blog post.
<h1>Firewall Rules</h1>
When apps need the users to add the app as an exception to the firewall, it translates into user confusion, additional user clicks, and/or denial of exception by mistake.

The Windows Security Alert does a good job of trying to educate the user, but it's still one more decision the user must make before they can use their app.

In addition, subsequent app updates will result in the same dialog to pop up and take the user through the same flow.

<img width="385" height="286" class="alignnone wp-image-286" alt="firewall" src="https://msdnshared.blob.core.windows.net/media/2017/03/Firewall.png" />

With the Creators Update, the developers can register for firewall rules ahead of time, so the users don't have to make a firewall choice prior to launching their apps (including after subsequent app updates).

&nbsp;

<strong>XML sample:</strong>

*Please note that this extension needs to be declared at the <span style="text-decoration: underline">package</span> level (not at the application level).
<div class="tabs">
<div title="xml">
<pre class="brush:xml;">
&lt;Package 
...
xmlns:desktop2="https://schemas.microsoft.com/appx/manifest/desktop/windows10/2"
...&gt;
...
&lt;Extensions&gt;
   &lt;desktop2:Extension Category="windows.firewallRules"&gt;
      &lt;desktop2:FirewallRules Executable="foo.exe"&gt;
         &lt;desktop2:Rule Direction="in" IPProtocol="TCP" Profile="all"/&gt;
         &lt;desktop2:Rule Direction="in" IPProtocol="UDP" LocalPortMin="1337" LocalPortMax="1338" Profile="domain"/&gt;
         &lt;desktop2:Rule Direction="in" IPProtocol="UDP" LocalPortMin="1337" LocalPortMax="1338" Profile="public"/&gt;
         &lt;desktop2:Rule Direction="out" IPProtocol="UDP" LocalPortMin="1339" LocalPortMax="1340" RemotePortMin="15" RemotePortMax="19" Profile="domainAndPrivate"/&gt;
         &lt;desktop2:Rule Direction="out" IPProtocol="GRE" Profile="private"/&gt;
      &lt;/desktop2:FirewallRules&gt;
   &lt;/desktop2:Extension&gt;
&lt;/Extensions&gt;
&lt;/Package&gt;

</pre>
</div>
</div>
<h2>Other noteworthy features</h2>
<ul>
 	<li>Apps can be pre-installed</li>
 	<li>Messaging Application Programming Interface (MAPI) support</li>
 	<li>Windows App Certification Kit now includes test cases for desktop bridge apps</li>
 	<li>UseURL flag enables apps to directly open files from a URL instead of downloading a local cached version of the file</li>
</ul>]]></content:encoded>
    </item>
    <item>
      <title>Desktop Bridge: Smooth User Transition &amp; Data Migration</title>
      <link>https://docs.microsoft.com/archive/blogs/universal-windows-app-model/desktop-bridge-smooth-user-transition-data-migration</link>
      <pubDate>Wed, 01 Mar 2017 08:27:41 GMT</pubDate>
      <dc:creator><![CDATA[Arian Ghotbi]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/universal-windows-app-model/?p=255</guid>
      <description><![CDATA[Overview
Users will be encouraged to download the store version of their desktop apps. If the user...]]></description>
      <content:encoded><![CDATA[<h1>Overview</h1>
Users will be encouraged to download the store version of their desktop apps. If the user already has the previous desktop version of the app, the transition experience should be as seamless as possible.

The <strong>Creators Update </strong>will provide the ability to provide this smooth experience along with some best practices for app developers to follow.

This feature is available in the Creators Update.

You can use the following GitHub sample:
https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/DesktopAppTransition

<h2></h2>
<h2>User Transition: Taskbar Pins &amp; Start Tiles</h2>
Many users typically pin their favorite or most used apps to the taskbar pin or the start menu. This enables them to access the app much faster.

With the Creators Update, app developers can re-route the taskbar pins and the start tile shortcuts to point to the store version of the desktop app.

&nbsp;

Here’s a sample AppXManifest.xml snippet which shows the declaration for this transition.

&nbsp;

You must use the following namespace:
<div class="tabs">
<div title="xml">
<pre class="brush:xml;">xmlns:rescap3="https://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities/3"</pre>
</div>
</div>
&nbsp;

This extension must be under the <em>&lt;Application&gt; </em>element.
<div class="tabs">
<div title="xml">
<pre class="brush:xml;">&lt;rescap3:Extension Category="windows.desktopAppMigration"&gt;
   &lt;rescap3:DesktopAppMigration&gt;
      &lt;rescap3:DesktopApp AumId="Foo.bar" /&gt;
      &lt;rescap3:DesktopApp ShortcutPath="%USERPROFILE%\Desktop\foo.lnk" /&gt;
      &lt;rescap3:DesktopApp ShortcutPath="%APPDATA%\Microsoft\Windows\Start Menu\Programs\foo.lnk" /&gt;
      &lt;rescap3:DesktopApp ShortcutPath="%PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\bar\foo.lnk"/&gt;
   &lt;/rescap3:DesktopAppMigration&gt;
&lt;/rescap3:Extension&gt;</pre>
</div>
</div>
&nbsp;

If you know your app’s <a target="_blank" href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx">Application User Model ID</a>, then it’s recommended that you use it for the transition.

Otherwise, you can use the path to your app’s shortcut (.lnk) file. If you don’t know where your app installs the shortcut, the easiest way to find it is to right-click on the app’s name from the start menu and select ‘<em>Open file location’</em>.

You have to make sure the path you use in the <em>AppXManifest.xml</em> uses the environment variables (one of <em>%USERPROFILE%</em>, <em>%APPDATA%</em>, or <em>%PROGRAMDATA%</em>). Most likely, the shortcut is under <em>%PROGRAMDATA%</em>.

&nbsp;
<h2>User Transition: File type associations &amp; protocol handlers</h2>
The user may choose their favorite app to be the default app for a given file type or protocol. With the Creators Update, the developers can also transition the user’s choice to use the store version of the same app.

Here’s the AppXManifest.xml snippet that shows how the Filetype Association is transitioned. The Protocol Handlers are transition in the same way.

&nbsp;

You must use the following namespace:
<div class="tabs">
<div title="xml">
<pre class="brush:xml;">xmlns:uap3=”https://schemas.microsoft.com/appx/manifest/uap/windows10/3”

</pre>
</div>
</div>
As part of this transition, you need to provide the <a target="_blank" href="https://msdn.microsoft.com/en-us/library/windows/desktop/cc144152(v=vs.85).aspx">Programmatic Identifier</a>.
<div class="tabs">
<div title="xml">
<pre class="brush:xml;">&lt;uap:Extension Category="windows.fileTypeAssociation"&gt;
&lt;uap3:FileTypeAssociation Name=“.foo”&gt;
   &lt;rescap3:MigrationProgIds&gt;
      &lt;rescap3:MigrationProgId&gt;Foo.Bar.1&lt;/rescap3:MigrationProgId&gt;
  &lt;/rescap3:MigrationProgIds&gt;
 …
 &lt;/uap3:FileTypeAssociation&gt;
&lt;/uap:Extension&gt;

</pre>
</div>
</div>
&nbsp;
<h2>Data Migration</h2>
As best practice, it is recommended for developers to attempt to migrate previous user data from the desktop app, upon first launch of the store version of the same app.

This will delight the users, so they can ‘pick up where they left off’.

Please refer to the code sample below to learn about the best practices around how to do this on first launch, while recognizing which version of your desktop app you are running (store version vs previous desktop version).
<h2>User Transition: Uninstall previous desktop app</h2>
As best practice, it is recommended for developers to offer uninstallation of the previous desktop app upon first launch of the store version of the app. This will help in avoiding user confusion and potential user data corruption.

Keep in mind that the user can refuse the uninstallation of the previous desktop app, so the previous and store version of the app may end up running side-by-side. It is up to the app developer to decide whether or not to block the launch of the store version of the app, until the previous desktop app is uninstalled.
<div class="tabs">
<div title="C#">
<pre class="brush:csharp;">//Please refer to the following blogpost to learn how you can use this method:
//https://blogs.msdn.microsoft.com/appconsult/2016/11/03/desktop-bridge-identify-the-applications-context/
if (IsRunningAsUwp())
{
   //Detect if there is previous user data
   //In this example, the previous user data was in the ApplicationData You should change this based on where the previous data was

   String sourceDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\AppName";
   if(Directory.Exists(sourceDir))
   {
      String migrateMessage = "Would you like to migrate your data from the previous version of this app?";
      MessageBoxResult migrateResult = MessageBox.Show(migrateMessage, "Data Migration", MessageBoxButton.YesNo);

      if (migrateResult.Equals(MessageBoxResult.Yes))
      {
         //Migrate user data
         String destinationDir = Windows.Storage.ApplicationData.Current.LocalFolder.Path + "\\AppName";

         //If you are moving data from one of the redirected folders, you need to use robocopy.exe to bypass redirection. This is the only time you should bypass redirection
         //Redirected folders: https://docs.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-behind-the-scenes
         //Robocopy.exe: https://technet.microsoft.com/en-us/library/cc733145(v=ws.11
        //Otherwise, you should move files using System.IO

         if (runProcess("robocopy.exe", sourceDir + " " + destinationDir + " /move") &gt; 1 )
         {
            //Migration was unsuccessful -- App Developer can choose to block/retry/other action
         }
      }
   }


   //Detect if the previous version of the Desktop App is installed
   //Typically your uninstall string lives under this

   String uninstallString = (String)Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{7AD02FB8-B85E-44BC-8998-F4803BA5A0E3}\", "UninstallString", null);

   if (uninstallString != null)
   {
      String uninstallMessage = "It is recommended that you uninstall the old version of this application in order to have a better experience. Would you like to uninstall the previous version of your app now?";
      MessageBoxResult uninstallResult = MessageBox.Show(uninstallMessage, "Uninstall the previous version", MessageBoxButton.YesNo);

      if (uninstallResult.Equals(MessageBoxResult.Yes))
      {
         //Run the uninstaller by using Process (see private method below)
         string[] uninstallArgs = uninstallString.Split(' ');
         if (runProcess(uninstallArgs[0], uninstallArgs[1]) != 0)
         {
            //Uninstallation was unsuccessful - App Developer can choose to block the app here
         }
      }
   }
}


private int runProcess(string appName, string arguments)
{
   Process process = new Process();
   process.StartInfo.FileName = appName;
   process.StartInfo.Arguments = arguments;
   process.StartInfo.CreateNoWindow = true;
   process.Start();
   process.WaitForExit();
   return process.ExitCode;
}
</pre>
</div>
</div>]]></content:encoded>
    </item>
    <item>
      <title>CompactOverlay mode - aka Picture-in-Picture</title>
      <link>https://docs.microsoft.com/archive/blogs/universal-windows-app-model/compactoverlay-mode-aka-picture-in-picture</link>
      <pubDate>Sat, 11 Feb 2017 01:19:12 GMT</pubDate>
      <dc:creator><![CDATA[rkarman]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/universal-windows-app-model/?p=225</guid>
      <description><![CDATA[Note: The new feature(s) covered in this post are available to Windows Insiders running build 15021...]]></description>
      <content:encoded><![CDATA[<strong>Note:</strong> The new feature(s) covered in this post are available to Windows Insiders running build 15021 or newer.

<strong>New in Creators Update: </strong>In the most recent Windows 10 Creators Update we introduce a new compact overlay mode for UWA app windows. When an app window enters compact overlay mode it’ll be shown above other windows so it won’t get blocked. This allows users to continue to keep an eye on your app's content even when they are working with something else. The canonical example of an app taking advantage of this feature is a media player or a video chat app.
<img alt="CompactOverlay feature used to create a picture-in-picture media player experience" src="https://winblogs.azureedge.net/win/2017/02/pip.png" />
<h2>Quick Summary</h2>
The ViewMode APIs that powers the CompactOverlay mode described in this blogpost have three parts:
<ul>
 	<li>the ability to check if CompactOverlay mode is available to the app at all</li>
 	<li>the ability to transition an existing view in and out of CompactOverlay mode</li>
 	<li>the ability to show a standalone view in CompactOverlay mode.</li>
</ul>
If you're not familiar with multiple views, just skip that part of this blogpost for now or go explore the <a href="https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/MultipleViews">MultipleViews github sample</a> then come back for that part.
<h2>The basics</h2>
For a single view app, which most UWP apps are, adding a compact overlay option to the app is easy and straight forward. First you put in some kind of UX affordance that lets the user switch modes (since this is a sample we go with a button), check if the view mode we want to enable is available (if so, make the button visible) and then change the view mode when the user taps on the UX affordance.
<h3>Is CompactOverlay supported?</h3>
Since the intent of the Compact Overlay view mode is a very specific type of user experience, it is not necessarily supported across all Windows devices and interaction modes. Best practice for the app developer is therefore to check whether it is supported before enabling the UX affordance in the app that lets users access this functionality.
<div class="tabs">
<div title="C#">
<pre class="brush: csharp; highlight: [1]">if (ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay))
{
    compactOverlayButton.Visibility = Visibility.Visible;
}
</pre>
</div>
</div>
<h3>Switching the view into CompactOverlay mode</h3>
At its core the CompactOverlay API is really about this one function call:
<div class="tabs">
<div title="C#">
<pre class="brush: csharp; highlight: [3]">private async void compactOverlayButton_Click(object sender, RoutedEventArgs e)
{
    bool modeSwitched = await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay);
}
</pre>
</div>
</div>
This API operates on the current ApplicationView of the app, transitioning it from one view mode into another, which in this case is from the default view mode into CompactOverlay mode. When this happens you will note some attributes changing for the window:
<ol>
 	<li>it will most likely become smaller than your app window was prior to the call</li>
 	<li>it will be moved to the top-right corner area of the screen</li>
 	<li>if you move focus away from the CompactOverlay window the title bar will disappear</li>
</ol>
To get back to your normal app layout window just call the same API again, but this time with a ApplicationViewMode.Default:
<div class="tabs">
<div title="C#">
<pre class="brush: csharp; highlight: [3]">private async void standardModeButton_Click(object sender, RoutedEventArgs e)
{
    bool modeSwitched = await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default);
}
</pre>
</div>
</div>
This will restore your application view to the size and position it had before going into CompactOverlay mode and you can navigate the user back to the app's main layout again.
<h2>Providing options for the view</h2>
When going into CompactOverlay you probably have a very specific experience in mind for the user, such as providing a mini-view of a video chat, or a certain scaled down version of a video where you want to make sure it can maintains its aspect ratio in the new view configuration.

To enable this we give you the ability to provide a ViewModePreferences object when calling the API. At the time of this post the only preference you can set that will be considered by the system when displaying your view is the CustomSize property which allows you to set the size of the view as it switches into the new mode.

ViewModePreference works a little different then other preference objects that you may have worked with in the windowing space before in that you have to create a default version of it for the mode you want and then then modify the object you get back, instead of just calling 'new' and setting all the preferences to the correct values. The reason for this is that we want to make sure that future additions to the object gets set properly for the mode you are modifying and that vital preferences are not missed as the bells'n'whistles of this API are extended.

If we wanted to set the window size to 320x200 when switching into CompactOverlay the code looks like this:
<div class="tabs">
<div title="C#">
<pre class="brush: csharp; highlight: [3,5]">private async void compactOverlayButton_Click(object sender, RoutedEventArgs e)
{
    ViewModePreferences compactOptions = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
    compactOptions.CustomSize = new Windows.Foundation.Size(320, 200);
    bool modeSwitched = await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default, compactOptions);
}
</pre>
</div>
</div>
<h2>Working with a separate view for CompactOverlay</h2>
As mentioned in the introduction you can also have new views show up as CompactOverlay views while your main app view remains untouched. The principle for this is the same as with multiview apps but we have added a new switcher API for transitioning the view directly into the specified mode as it is shown so that you avoid the flicker that would be the result of first showing the view as standalone (using TryShowAsStandaloneAsync) and then calling TryEnterViewMode on it.

The switcher API follows the same pattern as the API that acts on the current view, where you provide the mode you want to switch into and, if needed, the preferences for the view. In its most simple form the call would look like this:
<div class="tabs">
<div title="C#">
<pre class="brush: csharp; highlight: [12]">private async void ShowCompactView()
{
    await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =&gt;
    {
        var frame = new Frame();
        compactViewId = ApplicationView.GetForCurrentView().Id;
        frame.Navigate(typeof(SecondaryCompactViewPage));
        Window.Current.Content = frame;
        Window.Current.Activate();
        ApplicationView.GetForCurrentView().Title = "CompactOverlay Window";
    });
    bool viewShown = await ApplicationViewSwitcher.TryShowAsViewModeAsync(compactViewId, ApplicationViewMode.CompactOverlay);
}
</pre>
</div>
</div>
You can of course also set the preferred size of your pop-out window just as you did with the TryEnterViewMode, just add the ViewModePreferences to the TryShowAsViewModeAsync call and you're done!

For more details on how to work with CreateNewView, view switching APIs in general, and best practices for view lifetime control - please refer to the <a href="https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/MultipleViews">MultipleViews github sample</a>.]]></content:encoded>
    </item>
    <item>
      <title>How to ensure your toast notifications continue to work when converting your win32 app into a Windows Store app using project Centennial</title>
      <link>https://docs.microsoft.com/archive/blogs/universal-windows-app-model/how-to-ensure-your-toast-notifications-continue-to-work-when-converting-your-win32-app-into-a-windows-store-app-using-project-centennial</link>
      <pubDate>Tue, 31 Jan 2017 03:27:48 GMT</pubDate>
      <dc:creator><![CDATA[Arian Ghotbi]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/universal-windows-app-model/?p=195</guid>
      <description><![CDATA[[Originally posted by Lei Xu]

&nbsp;

As you may already know, developer can now bring their...]]></description>
      <content:encoded><![CDATA[[<a href="https://blogs.msdn.microsoft.com/tiles_and_toasts/2016/09/26/how-to-ensure-your-toast-notifications-continue-to-work-when-converting-your-win32-app-into-a-windows-store-app-using-project-centennial/">Originally posted by Lei Xu</a>]

&nbsp;

As you may already know, developer can now bring their existing apps and games to the Windows Store with the Desktop Bridge, known as <a href="https://developer.microsoft.com/en-us/windows/bridges/desktop">project Centennial</a>.

For developers who has been integrating with toast notification features in Windows 8 and Windows 10, when you turn your app into a Windows Store app using project Centennial, you may realize that your toast notification does not work as desired – an incorrect/unresolved string will show up in Action Center at where the application title is supposed to be shown. This post summarizes on why it happens and how to fix it with a simple change to your code.
<h2>Why does it break?</h2>
In Windows 8/8.1, we enabled support for desktop Win32 apps to send local toast notifications – by enabling win32 apps to do 2 things:
<ul>
 	<li>be able to register with the notification platform and;</li>
 	<li>call WinRT APIs to send toast.</li>
</ul>
What did we do to enable those respectively?
<ul>
 	<li>A registration with notification platform requires an app identity, but win32 apps don’t really have modern app identities. This problem is solved by by allowing win32 apps to provide us with a “fake” app identity – <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/hh802762(v=vs.85).aspx">through creating a desktop shortcut</a>.</li>
 	<li>The app will then need to call the method overload that takes this manually created application id to indicate which identity is trying to send this notification, as shown:
<div>
<div class="syntaxhighlighter nogutter  csharp" id="highlighter_629008">
<div class="toolbar"><span><a href="https://blogs.msdn.microsoft.com/tiles_and_toasts/2016/09/26/how-to-ensure-your-toast-notifications-continue-to-work-when-converting-your-win32-app-into-a-windows-store-app-using-project-centennial/#" class="toolbar_item command_help help">?</a></span></div>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="code">
<div class="container">
<div class="line number1 index0 alt2"><code class="csharp plain">ToastNotificationManager.CreateToastNotifier(appId).Show(toast);</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div></li>
</ul>
Windows Store apps converted through project Centennial on the other side, already come with proper app identities just like any regular UWP app, so if the win32 app is converted without changing any of its previous code, then it will create a conflict as below:
<ul>
 	<li>The shortcut creation will be skipped for the converted Store app during app deployment because the deployment path is different, however;</li>
 	<li>The app will still call the same overload mentioned above to pass in the fake app id that the OS can no longer resolve, since the shortcut is not there, thus results in unresolved string.</li>
</ul>
<h2>How to fix it?</h2>
Any app in this situation will need to simply change a line of their code to call
<div>
<div class="syntaxhighlighter nogutter  csharp" id="highlighter_478788">
<div class="toolbar"><span><a href="https://blogs.msdn.microsoft.com/tiles_and_toasts/2016/09/26/how-to-ensure-your-toast-notifications-continue-to-work-when-converting-your-win32-app-into-a-windows-store-app-using-project-centennial/#" class="toolbar_item command_help help">?</a></span></div>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="code">
<div class="container">
<div class="line number1 index0 alt2"><code class="csharp plain">ToastNotificationManager.CreateToastNotifier().Show(toast);</code></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
without passing in the manually created appId and just let the app identity get resolved by the OS like any other modern apps do.
<h2>Why didn’t we fix this for you?</h2>
The same method overload can also be used by Windows Store apps to send toast notifications on behalf of other apps in the same package. Once a win32 app is converted to Windows Store app through project Centennial, Windows just see it as a regular Store app without knowing its true intention behind calling CreateToastNotifier(appId). To prevent us from getting your real intention wrong and further break some other unexpected scenarios, we ask the developers to make the change here during your conversion process.]]></content:encoded>
    </item>
    <item>
      <title>“UWPDesktop” NuGet Package Version 14393</title>
      <link>https://docs.microsoft.com/archive/blogs/universal-windows-app-model/uwpdesktop-nuget</link>
      <pubDate>Wed, 14 Dec 2016 03:01:00 GMT</pubDate>
      <dc:creator><![CDATA[Vladimir Postel]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/universal-windows-app-model/?p=1</guid>
      <description><![CDATA[The UWPDesktop NuGet package is here to improve the developer experience with Visual Studio when...]]></description>
      <content:encoded><![CDATA[The UWPDesktop <em>NuGet</em> package is here to improve the developer experience with Visual Studio when walking along the <a href="https://developer.microsoft.com/en-us/windows/bridges/desktop">Desktop Bridge</a>. The Desktop Bridge allows you to call UWP APIs directly from your WinForms, WPF or VB application. You can use APIs such as Live tiles, Notifications, App Services and <a href="https://msdn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-supported-api">many more!</a>

Previously, calling UWP APIs from a converted app was a confusing process. You had to find and reference the right .dll or .winmd, and it often wasn’t obvious which one to choose. For example, to use "await" on WinRT types, you had to reference the System.Runtime.WindowsRuntime.dll (c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll), which was actually from Windows 8.1 and therefore only worked in conjunction with "facade\windows.winmd" (c:\Program Files (x86)\Windows Kits\10\UnionMetadata\Facade\Windows.WinMD)


<div class="tabs">
<div title="C#">
<pre class="brush:csharp;">

AppServiceConnectionStatus status = await connection.OpenAsync();

</pre>
</div>
</div>

Confusing, right? The new way is much simpler – just include the <a href="https://www.nuget.org/packages/UwpDesktop/10.0.14393.3">latest UWPDesktop NuGet</a> package to your project, and you’re ready to call any supported UWP API without needing additional references.

You have two options for installing the package:
<ol>
 	<li>In Visual Studio, right click on your project, select “Manage <em>NuGet</em> Packages”, and search for and install the UWPDesktop package (as shown in the screen shot below):</li>
<img src="https://msdnshared.blob.core.windows.net/media/2016/12/UWPDesktop.png" alt="uwpdesktop" width="650" class="alignnone size-full wp-image-16" />

 	<li>Use the <a href="https://docs.nuget.org/docs/start-here/using-the-package-manager-console">Package Manager Console </a></li>
</ol>

<div class="tabs">
<div title="PowerShell">
<pre class="brush:csharp;">

Install-Package UwpDesktop

</pre>
</div>
</div>

<h3>Warnings for unsupported WinRT APIs</h3>

Not all modern APIs can be called directly from your desktop application; for example, you still can’t use XAML or SecondaryTile in your WinForms app. The UWPDesktop <em>NuGet</em> package makes your life easier by raising a <strong>warning</strong> if you try and call an unsupported API.
<img src="https://msdnshared.blob.core.windows.net/media/2016/12/SecondaryTileWarnning2.png" alt="secondarytilewarnning2" width="1045" height="426" class="alignnone size-full wp-image-145" />

<h3>Resources</h3><ul>
<li><a title="Full code on GitHub" href="https://github.com/ljw1004/uwp-desktop" target="_blank">Full code on GitHub</a></li>
<li><a href="https://www.nuget.org/packages/UwpDesktop/10.0.14393.3" target="_blank">The NuGet package</a></li>
<li><a href="https://developer.microsoft.com/en-us/windows/bridges/desktop" target="_blank">Desktop Bridge Documentation</a></li>
</ul>

&nbsp;

Any questions? Leave them in the comments!

Enjoy! 
Vladimir Postel, Program Manager – Windows Developer Platform]]></content:encoded>
    </item>
  </channel>
</rss>