【问题标题】:launching a uri from my app in half screen mode C# windows 8.1 app以半屏模式从我的应用程序启动 uri C# windows 8.1 应用程序
【发布时间】:2014-03-15 17:17:27
【问题描述】:

我正在尝试从我的 Windows 8.1 应用程序启动一个 uri,但无法让它在 UseHalf 模式下启动 研究了一下,发现应该是这样的

       LauncherOptions lo = new LauncherOptions();
       lo.DesiredRemainingView = ViewSizePreference.UseHalf;
       lo.DisplayApplicationPicker = true;
       await Windows.System.Launcher.LaunchUriAsync(new Uri("http://www.youtube.com"),lo);

但它一直全屏启动网络浏览器 我读到启动取决于许多变量,并且不能保证将应用这些设置

我的问题是有没有办法确保我的应用和浏览器在半屏模式下并排打开?

【问题讨论】:

  • 请检查答案或向我们添加更多帮助

标签: c# .net windows-store-apps uri windows-8.1


【解决方案1】:

它必须工作:

Uri uri = new Uri("http://www.youtube.com");
LauncherOptions options = new LauncherOptions
{
    DesiredRemainingView = ViewSizePreference.UseHalf
};

await Launcher.LaunchUriAsync(uri, options);

如果不行,请试试这个长代码:

ApplicationView currentAppView = ApplicationView.GetForCurrentView();  

CoreApplicationView newCoreAppView = CoreApplication.CreateNewView();  

newCoreAppView.Dispatcher.RunAsync(  
  CoreDispatcherPriority.Normal,  
  async () =>  
  {  
    // This executes on the new dispatcher so I assume that Window.Current and so on  
    // reflects the new Window associated with that dispatcher rather than the original  
    // dispatcher.  
    Window newWindow = Window.Current;  
    ApplicationView newAppView = ApplicationView.GetForCurrentView();  


    await ApplicationViewSwitcher.TryShowAsStandaloneAsync(  
      newAppView.Id,  
      ViewSizePreference.UseHalf,  
      currentAppView.Id,  
      ViewSizePreference.UseHalf);  
  });

来自Here

【讨论】:

  • nop 由于某种原因它不起作用,当我从我的应用程序调用此代码时它完全消失并且浏览器打开完整尺寸
  • 好吧,第二种方式确实并排打开了两个窗口,但我没有找到一种方法来设置第二个窗口以在浏览器中显示 uri
【解决方案2】:

在咨询 msdn 开发者论坛后发现这是唯一的方法 并且应用程序无法强制这种行为,此代码的结果取决于浏览器的设置和许多其他变量

【讨论】:

    猜你喜欢
    • 2015-06-28
    • 2015-08-24
    • 1970-01-01
    • 2014-01-21
    • 1970-01-01
    • 1970-01-01
    • 2016-01-21
    • 2014-06-07
    • 2012-06-14
    相关资源
    最近更新 更多