在半屏模式下从我的应用启动 URI C# Windows 8.1 应用

本文关键字:应用 URI 启动 Windows 我的 模式 | 更新日期: 2023-09-27 18:36:21

我正在尝试从我的 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);

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

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

在半屏模式下从我的应用启动 URI C# Windows 8.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);  
  });

从这里。

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