title: Creating a metro style app and adding it to openwith context menu
body: <p>I'm willing to create a metro style app similar to Windows Photo Viewer.</p>
  
  <p>For that I need to add my app in the Openwith context menu. Also, the image file selected in the windows explorer should open in my Photo Viewer. How to open the app with the selected image file as a parameter?</p>
  
  <p>Thanks in advance</p>
  
  <hr>
  
  <p>Thanks a lot @Filip</p>
  
  <p>I wrote the following code in <code>OnFileActivated(FileActivatedEventArgs args)</code> in <code>App.xaml.cs</code></p>
  
  <pre><code>protected override void OnFileActivated(FileActivatedEventArgs args)
          {
              // TODO: Handle file activation
  
              // The number of files received is args.Files.Size
              // The first file is args.Files[0].Name
              base.OnFileActivated(args);
              StorageFile file = args.Files[0] as StorageFile;
  
              Frame rootFrame = Window.Current.Content as Frame;
  
              if (rootFrame == null)
              {
                  // Create a Frame to act as the navigation context and navigate to the first page
                  rootFrame = new Frame();
                  //rootFrame.SourcePageType = typeof(ImageViewer);
  
                  if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                  {
                      //TODO: Load state from previously suspended application
                  }
  
                  // Place the frame in the current Window
                  Window.Current.Content = rootFrame;
              }
  
              if (rootFrame.Content == null)
              {
                  // When the navigation stack isn't restored navigate to the first page,
                  // configuring the new page by passing required information as a navigation
                  // parameter
                  if (!rootFrame.Navigate(typeof(ImageViewer), file))
                  {
                      throw new Exception("Failed to create initial page");
                  }
              }
              // Ensure the current window is active
              Window.Current.Activate();
          }
  </code></pre>
  
  <p>But, my app doesn't display anything on opening. So what according to you can be the flaw?</p>