【发布时间】:2018-02-25 05:56:24
【问题描述】:
我正在开发一个快速应用程序,其唯一目的是在 UWP 中使用画中画模式(紧凑视图)在我的作品之上显示 Youtube 视频。以下是当前系统的工作方式:
MainPage - 处理 youtube 视频的搜索 YoutubeItem - 主页为每个 youtube 结果创建的用户控件。其中大约 50 个被放入包装面板中。 YoutubeViewer - 在自己的窗口中运行并显示 youtube 视频的单独页面。
这是我的问题。我将 youtube 视频的所有信息存储在每个 YoutubeItems 中。使用一个按钮,我记录点击事件并处理它。这是处理点击的代码:
private async void Button_Click(object sender, RoutedEventArgs e)
{
CoreApplicationView newView = CoreApplication.CreateNewView();
int newViewId = 0;
await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
Frame frame = new Frame();
frame.Navigate(typeof(YoutubeViewer), null);
Window.Current.Content = frame;
// You have to activate the window in order to show it later.
Window.Current.Activate();
newViewId = ApplicationView.GetForCurrentView().Id;
});
bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);
}
当我必须将视频的链接发送到 YoutubeViewer 时,就会出现问题。最初,我是通过构造函数执行此操作的,但是在将这种方法用于 Windows 文档时,据我所知,我无法使用自己的构造函数。你们建议如何获取指向新窗口的链接?
【问题讨论】: