包含带视频的Web视图的弹出元素

时间:2013-05-15 12:05:37

标签: c# windows-8

是否可以使用uri源创建包含web视图的弹出元素(例如http://www.youtube.com/embed/z-m6Ua9Iqkg)? 单击按钮后,如何在屏幕中央显示弹出窗口?

1)是的,我搜索了互联网,但我不知道如何将网页视图元素放入弹出窗口,因为点击它后只显示空白的白色矩形(5x10)。 2)我使用了flyout callipso,再次只显示空白的白色矩形(5x10):

        Flyout flyOut = new Flyout();
        flyOut.PlacementTarget = sender as UIElement;
        flyOut.Placement = PlacementMode.Top;

        WebView web = new WebView();
        web.HorizontalAlignment=HorizontalAlignment.Center;
        web.VerticalAlignment = VerticalAlignment.Center;
        string html = "http://www.youtube.com/embed/z-m6Ua9Iqkg";

        flyOut.Content = web;
        web.NavigateToString(html);
        flyOut.IsOpen = true;

        UpdateLayout();

最后,我有这个(问题解决了,感谢来自MSDN的Sachin S),我希望这有助于某人:

Popup popup = new Popup();

        Grid panel = new Grid();

        panel.Height = 250;
        panel.Width = 250;

        panel.Transitions = new TransitionCollection();
        panel.Transitions.Add(new PopupThemeTransition());
        WebView web = new WebView();
        //web.HorizontalAlignment = HorizontalAlignment.Center;
        //web.VerticalAlignment = VerticalAlignment.Center;
        web.Navigate(item.PlayerUri);
        popup.Child = panel;
        panel.Children.Add(web);
        popup.HorizontalAlignment = HorizontalAlignment.Center;
        popup.VerticalAlignment = VerticalAlignment.Center;


        popup.HorizontalOffset = (Window.Current.Bounds.Width / 2 - panel.Width / 2);
        popup.VerticalOffset = (Window.Current.Bounds.Height / 2 - panel.Height / 2);

        popup.IsOpen = true;
        UpdateLayout(); 

1 个答案:

答案 0 :(得分:1)

最后,我有这个(问题解决了,感谢来自MSDN的Sachin S),我希望这有助于某人:

Popup popup = new Popup();

        Grid panel = new Grid();

        panel.Height = 250;
        panel.Width = 250;

        panel.Transitions = new TransitionCollection();
        panel.Transitions.Add(new PopupThemeTransition());
        WebView web = new WebView();
        //web.HorizontalAlignment = HorizontalAlignment.Center;
        //web.VerticalAlignment = VerticalAlignment.Center;
        web.Navigate(item.PlayerUri);
        popup.Child = panel;
        panel.Children.Add(web);
        popup.HorizontalAlignment = HorizontalAlignment.Center;
        popup.VerticalAlignment = VerticalAlignment.Center;


        popup.HorizontalOffset = (Window.Current.Bounds.Width / 2 - panel.Width / 2);
        popup.VerticalOffset = (Window.Current.Bounds.Height / 2 - panel.Height / 2);

        popup.IsOpen = true;
        UpdateLayout();