Click here to Skip to main content
15,893,622 members
Home / Discussions / WPF
   

WPF

 
QuestionWPF MVVM Multiple Vs with one VM Pin
_Maxxx_15-Jul-10 19:51
professional_Maxxx_15-Jul-10 19:51 
AnswerRe: WPF MVVM Multiple Vs with one VM Pin
Arun Jacob15-Jul-10 21:47
Arun Jacob15-Jul-10 21:47 
GeneralRe: WPF MVVM Multiple Vs with one VM Pin
_Maxxx_16-Jul-10 0:20
professional_Maxxx_16-Jul-10 0:20 
GeneralRe: WPF MVVM Multiple Vs with one VM Pin
_Maxxx_16-Jul-10 0:24
professional_Maxxx_16-Jul-10 0:24 
GeneralRe: WPF MVVM Multiple Vs with one VM Pin
Arun Jacob16-Jul-10 0:28
Arun Jacob16-Jul-10 0:28 
GeneralRe: WPF MVVM Multiple Vs with one VM Pin
Pete O'Hanlon16-Jul-10 1:38
mvePete O'Hanlon16-Jul-10 1:38 
AnswerRe: WPF MVVM Multiple Vs with one VM Pin
Jammer15-Jul-10 22:45
Jammer15-Jul-10 22:45 
QuestionHow to set the youtube player location fix in a xaml page, its getting on the botton of the page ...instead of the right position. Pin
Ch.Gayatri Subudhi15-Jul-10 19:10
Ch.Gayatri Subudhi15-Jul-10 19:10 
Hi,

I took a class for youtube player and create a instance of that youtube player in Page3.xaml page..The issue is at runtime (F5), in the application i got the youtube video in the bottom of the page and even its there for each and every xaml pae while i am navigating..how to resolve this issue for setting the youtube video exact position where i want and stop reflecting to other pages .The code is as below:
in Class1.cs
-------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Windows.Browser;


namespace K12
{
	
			public class YouTubePlayer : IDisposable
    {

        /// <summary>
        /// The default with of a player, if none is specified.
        /// </summary>
        public const int DefaultWidth = 425;

        /// <summary>
        /// The default height of a player, if none is specified.
        /// </summary>
        public const int DefaultHeight = 344;

        #region Private properties
        private string uniqueId = Guid.NewGuid().ToString();

        private double top;
        private double left;
        private double height = DefaultHeight;
        private double width = DefaultWidth;

        private string videoId;
        private bool isEmbeded;
        private HtmlElement div;
        #endregion

        /// <summary>
        /// Creates a player for the given video id. You must invoke Embed()
        /// later, to actually insert the video into the page.
        /// </summary>
        /// <param name="videoId"></param>
        public YouTubePlayer(string videoId)
        {
            this.videoId = videoId;
        }

        /// <summary>
        /// The absolute y position of this player.
        /// </summary>
        public double Top
        {
            get { return top; }
            set
            {
                top = value;

                if (isEmbeded)
                {
                    SetStyleProperty(DivId, "top", "\"" + (int)top + "px\"");
                }
            }
        }

        /// <summary>
        /// The absolute x position of this player.
        /// </summary>
        public double Left
        {
            get { return left; }
            set
            {
                left = value;

                if (isEmbeded)
                {
                    SetStyleProperty(DivId, "left", "\"" + (int)left + "px\"");
                }
            }
        }

        /// <summary>
        /// The height of this player.
        /// </summary>
        public double Height
        {
            get { return height; }
            set
            {
                height = value;

                if (isEmbeded)
                {
                    SetAllDivsProperty("height", "\"" + (int)height + "px\"");
                }
            }
        }

        /// <summary>
        /// The width of this player.
        /// </summary>
        public double Width
        {
            get { return width; }
            set
            {
                width = value;

                if (isEmbeded)
                {
                    SetAllDivsProperty("width", "\"" + (int)width + "px\"");
                }
            }
        }

        /// <summary>
        /// Allow fullscreen to be activated?
        /// </summary>
        public bool AllowFullScreen { get; set; }

        /// <summary>
        /// Embeds this player into the HTML page. Invoking this method many
        /// times has no effect. You must invoke Dipose() to remove the player
        /// form the HTML page.
        /// </summary>
        public void Embed()
        {
            if (isEmbeded) return;
            isEmbeded = true;

            div = HtmlPage.Document.CreateElement("div");
            div.SetAttribute("id", DivId);
            div.SetAttribute("style", "position: absolute; width:" + (int)Width + "px; height:" + (int)Height + "px; top: " + (int)Top + "px; left: " + (int)Left + "px; z-index:10");
            div.SetProperty("innerHTML",
                "<object width=\"" + (int)Width + "\" height=\"" + (int)Height + "\" id=\"" + ObjectId + "\">" +
                    "<param name=\"movie\" value=\"http://www.youtube.com/v/" + videoId + "&hl=en&fs=1\"></param>" +
                    "<param name=\"allowFullScreen\" value=\"" + AllowFullScreen + "\"></param>" +
                    "<embed id=\"" + EmbedId + "\" src=\"http://www.youtube.com/v/" + videoId + "&hl=en&fs=1\" type=\"application/x-shockwave-flash\" allowfullscreen=\"" + AllowFullScreen + "\" width=\"" + (int)Width + "\" height=\"" + (int)Height + "\"></embed>" +
                "</object>"
                );

            HtmlPage.Document.Body.AppendChild(div);
        }

        /// <summary>
        /// Removes this embedded player from the HTML page. Has no effect if this
        /// player was not embedded, or is already disposed.
        /// </summary>
        public void Dispose()
        {
            if (!isEmbeded) return;
            isEmbeded = false;

            HtmlPage.Document.Body.RemoveChild(div);
        }

        #region Implementation

        private string DivId { get { return "YouTubePlayer" + uniqueId; } }

        private string ObjectId { get { return "YouTubePlayer_Object_" + uniqueId; } }

        private string EmbedId { get { return "YouTubePlayer_Embed_" + uniqueId; } }

        private void SetAllDivsProperty(string property, object value)
        {
            SetProperty(DivId, property, value);
            SetProperty(ObjectId, property, value);
            SetProperty(EmbedId, property, value);
        }

        private void SetProperty(string divId, string property, object value)
        {
            HtmlPage.Window.Eval("document.getElementById(\"" + divId + "\")." + property + " = " + value + ";");
        }

        private void SetStyleProperty(string divId, string property, object value)
        {
            HtmlPage.Window.Eval("document.getElementById(\"" + divId + "\").style." + property + " = " + value + ";");
        }

        #endregion
    }
// Insert code required on object creation below this point.
	
	}


In Page3.xaml.cs
----------------

private void Page3_Loaded(object sender, System.Windows.RoutedEventArgs e)
       {

           YouTubePlayer player = new YouTubePlayer("5_a4zb9D4m4")
                  {
                   //Top = stalkpanel1.Marging.TOP+10,
                  // Left = stalkpanel1.Marging.Left+10,
                      Top = 100,
                      Left = 200,
                      Width = 400,
                      Height = 400
                 };


                player.Embed();

       }




Plz suggest me..Thanks in Advance

With Regards
Ch.Gayatri
QuestionWPF equivalent of anchoring controls? Pin
Michael Eber15-Jul-10 10:29
Michael Eber15-Jul-10 10:29 
AnswerRe: WPF equivalent of anchoring controls? Pin
Kubajzz15-Jul-10 11:05
Kubajzz15-Jul-10 11:05 
GeneralRe: WPF equivalent of anchoring controls? Pin
Michael Eber15-Jul-10 11:19
Michael Eber15-Jul-10 11:19 
AnswerRe: WPF equivalent of anchoring controls? Pin
Jammer15-Jul-10 22:24
Jammer15-Jul-10 22:24 
QuestionWPF Resources Pin
t_zano15-Jul-10 8:53
t_zano15-Jul-10 8:53 
AnswerRe: WPF Resources Pin
Parwej Ahamad15-Jul-10 19:52
professionalParwej Ahamad15-Jul-10 19:52 
QuestionToolkit DataGrid background in the edit mode [modified] Pin
ds4115-Jul-10 6:57
ds4115-Jul-10 6:57 
QuestionC++ structure decoding in silverlight Pin
JS 200815-Jul-10 3:09
JS 200815-Jul-10 3:09 
AnswerRe: C++ structure decoding in silverlight Pin
KarstenK15-Jul-10 3:58
mveKarstenK15-Jul-10 3:58 
GeneralRe: C++ structure decoding in silverlight Pin
JS 200815-Jul-10 20:24
JS 200815-Jul-10 20:24 
QuestionHow to get rid of "Enter text here" in DatePicker? Pin
makumazan8415-Jul-10 1:21
makumazan8415-Jul-10 1:21 
AnswerRe: How to get rid of "Enter text here" in DatePicker? Pin
Abhinav S15-Jul-10 2:08
Abhinav S15-Jul-10 2:08 
QuestionStyles in WPF.. help me !! Pin
Hema Bairavan14-Jul-10 23:24
Hema Bairavan14-Jul-10 23:24 
AnswerRe: Styles in WPF.. help me !! Pin
Parwej Ahamad15-Jul-10 19:47
professionalParwej Ahamad15-Jul-10 19:47 
QuestionSilverlight ASCII values Pin
Santhosh Sebastian Mattathil14-Jul-10 20:05
Santhosh Sebastian Mattathil14-Jul-10 20:05 
AnswerRe: Silverlight ASCII values Pin
Abhinav S15-Jul-10 6:50
Abhinav S15-Jul-10 6:50 
QuestionWPF DataGrid and asp.net like editItemTemplate? Pin
devvvy14-Jul-10 0:25
devvvy14-Jul-10 0:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.