2016-02-16 57 views
1

我使用Intense模板製作UWP應用程序,問題是我無法制作共享作品,因爲我不知道如何從app.xaml導航。 CS使用此模板。無法制作共享作品

protected override async void OnShareTargetActivated(ShareTargetActivatedEventArgs args) 
    { 
     ShareOperation shareOperation = args.ShareOperation; 
     //Can't make any navigation 
    } 

回答

0

你可以得到微軟的源代碼來檢索Frame對象

private Frame CreateRootFrame() 
    { 
     Frame rootFrame = Window.Current.Content as Frame; 
     // Do not repeat app initialization when the Window already has content, 
     // just ensure that the window is active 
     if (rootFrame == null) 
     { 
      // Create a Frame to act as the navigation context and navigate to the first page 
      rootFrame = new Frame(); 
      // Place the frame in the current Window 
      Window.Current.Content = rootFrame; 
     } 

     return rootFrame; 
    } 

,並使用像你想

protected override void OnShareTargetActivated(ShareTargetActivatedEventArgs args) 
    { 
     var rootFrame = CreateRootFrame(); 
     // your page and share operation as navigation parameters 
     rootFrame.Navigate(typeof(ShareTargetPage), args.ShareOperation); 
     Window.Current.Activate(); 
    } 

Microsoft Sample Project

+0

我會嘗試儘快我回家,謝謝。 –

+0

我不斷收到「System.Exception」,如果我試圖結束共享與「shareOperation.ReportCompleted()」它崩潰了。 –