.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> WPF >> Post New Resource Bookmark and Share   

 Subscribe to Articles

WPF Full Screen View For Media Element

Posted By:Diptimaya Patra       Posted Date: April 22, 2010    Points: 25    Category: WPF    URL: http://www.dotnetspark.com  

WPF Full Screen View For Media Element. In this article we will see how we can make the Media Element to run Full Screen.


In the previous article about "Seek bar For Media Element in WPF", we saw how to seek the Media Element to the desired position. In this article we will see how we can make the Media Element to run FullScreen.

Creating WPF Application Project

Fire up Visual Studio 2008 and Create a WPF Application and name the project as MediaSampleWPF.


I am just extending the feature that we experienced in our last application titled "Media Element In WPF", "Screenshot From Media Element in WPF", and "Seek bar For Media For Media Element In WPF".

As in the Timer Controls Tick event we are doing something, let's add a piece of code that would help us making the Media Element Full Screen run properly.


Code View of the above Image

void timer_Tick(object sender, EventArgs e)
    if (!isDragging)
        seekBar.Value = MediaEL.Position.TotalSeconds;
        currentposition = seekBar.Value;

We will make the MediaElement to show as FullScreen on MouseDoubleClick, but there is a road block for us. We don't have LeftMouseDoubleClick event for MediaElement.

So we will tweak this in following manner, we will take up the System's Double Click Time and use it in our LeftMouseButtonUp event.

#region FullScreen
static extern uint GetDoubleClickTime();

System.Timers.Timer timeClick = new System.Timers.Timer((int)GetDoubleClickTime())
    AutoReset = false

Above timer will be similar to System's DoubleClickTime.

bool fullScreen = false;
double currentposition = 0;

private void MediaEL_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    if (!timeClick.Enabled)
        timeClick.Enabled = true;

    if (timeClick.Enabled)
        if (!fullScreen)
            this.Background = new SolidColorBrush(Colors.Black);
            this.Content = MediaEL;
            this.WindowStyle = WindowStyle.None;
            this.WindowState = WindowState.Maximized;
            MediaEL.Position = TimeSpan.FromSeconds(currentposition);
            this.Content = LayoutRoot;
            this.Background = new SolidColorBrush(Colors.White);
            this.WindowStyle = WindowStyle.SingleBorderWindow;
            this.WindowState = WindowState.Normal;
            MediaEL.Position = TimeSpan.FromSeconds(currentposition);
        fullScreen = !fullScreen;

The above code should work for making the Full Screen view. Let's test it.

Run the application and Double Click on the Media Element. Now you can see the Media Element running in Full Screen Mode.


In Full Screen View:


You can also download the sample project used in the above example

Hope this article helps.

 Subscribe to Articles


Further Readings:

Author: Nikhil Kumar         Company URL: http://www.dotnetspark.com
Posted Date: April 23, 2010

your articles always looks interactive... thats nice

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend