2017-01-02 45 views
0

在我的应用程序中,我调用LaunchUriAsync方法时添加了逻辑以使应用程序处于前台。 但我可以找到各种选项将控件放在页面的前面,但我想在启动时关注页面。 请分享建议,如果你有。关注UWP中的主页

+0

欢迎来到Stack Overflow!你可以先参加[游览]并学习[问]一个很好的问题,然后创建一个[mcve]。这使我们更容易帮助你。 – Katie

回答

0

在我看来,一旦您使用LaunchUriAsync方法启动应用程序,应用程序的OnActivated事件将被解雇。您可以在此处理程序方法中导航到MainPage,并通过调用Window.Current.Activate()来将应用程序窗口置于前景并将输入焦点设置为它。

protected override void OnActivated(IActivatedEventArgs args) 
{ 
    base.OnActivated(args); 
    if (args.Kind == ActivationKind.Protocol) 
    { 
     Frame rootFrame = Window.Current.Content as Frame; 
     if (rootFrame == null) 
     { 
      rootFrame = new Frame(); 
      rootFrame.Navigate(typeof(MainPage)); 
      Window.Current.Content = rootFrame; 
     } 
    } 
    Window.Current.Activate(); 
} 
+0

其实,我已经尝试过,但应用程序图标仍然只闪烁,但它没有将应用程序放在前台。 – Priya

+0

@Priya您能否向我提供一个[最小,完整和可验证的示例](http://stackoverflow.com/help/mcve)? –