Saturday, October 6, 2012

FullScreen mode from ChildWindow

FullScreen mode from ChildWindow

Hi all, I have a ChildWindow that contains a SMF Media Player. Does anyone knows how to go FullScreen mode from the ChildWindow? When I apply my code only the parent container goes FullScreen but the ChWindow stays the same size. Private Sub SmPlayer_FullScreenChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SmPlayer.FullScreenChanged Dim chw As New SaxgeekVideoChildWindow If chw.SmPlayer.IsFullScreen = True Then SmPlayer.Width = App.Current.Host.Content.ActualWidth SmPlayer.Height = App.Current.Host.Content.ActualHeight End If chw.Height = 460 chw.Width = 600 End Sub Any idea on how to? And will this be done from the MainPage.xaml.vb or the ChildWindow.xaml.vb? Thanks, Hernan

Answers & Comments...

Answer: 1

Hi,

Assume there is nothing in your MainPage, and here is a solution for you:

C# code:

        private void SMFPlayer_FullScreenChanged(object sender, EventArgs e)
        {

            SMFPlayer p = sender as SMFPlayer;
            // The RootVisual is MainPage, check this out from App.xaml.cs
            MainPage mp = App.Current.RootVisual as MainPage;

            if (p.IsFullScreen == true)
            {
                // Remove the palyer from the Childwindow
                LayoutRoot.Children.Remove(p);
                // Add the player to the MainPage
                mp.LayoutRoot.Children.Add(p);

                // Hide the childwindow
                this.Visibility = Visibility.Collapsed;
            }

            if (p.IsFullScreen == false)
            {
                // Remove the player from the MainPager
                mp.LayoutRoot.Children.Remove(p);
                // Add the player to ChildWindow
                LayoutRoot.Children.Add(p);

                // Show the Childwindow
                this.Visibility = Visibility.Visible;
            }
        }

VB code:

    Private Sub SMFPlayer_FullScreenChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim p As SMFPlayer = TryCast(sender, SMFPlayer)
        ' The RootVisual is MainPage, check this out from App.xaml.cs
        Dim mp As MainPage = TryCast(App.Current.RootVisual, MainPage)

        If p.IsFullScreen = True Then
            ' Remove the palyer from the Childwindow
            LayoutRoot.Children.Remove(p)
            ' Add the player to the MainPage
            mp.LayoutRoot.Children.Add(p)

            ' Hide the childwindow
            Me.Visibility = Visibility.Collapsed
        End If

        If p.IsFullScreen = False Then
            ' Remove the player from the MainPager
            mp.LayoutRoot.Children.Remove(p)
            ' Add the player to ChildWindow
            LayoutRoot.Children.Add(p)

            ' Show the Childwindow
            Me.Visibility = Visibility.Visible
        End If

    End Sub

If there are other content in your Mainpage, then you can use a container that as below:

http://forums.silverlight.net/forums/t/217776.aspx

Hope this helps.

 

Regards



Answer: 2

I suggest you put the player in MainPage or other UserControl, and use VisualStateManager to hide (Visibility.Collapsed) other elements.



Answer: 3

great post , that really helped Daoping

but still there's a problem, after fullscreen the player control bar disabled.

any help is highly appreciated





No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog