Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have two displays. I want to make a media player and I want to play video full screen on my secondary display. So I’m trying to make a media player using WPF

Here is the code so far I wrote

Screen[] _screens = Screen.AllScreens;
System.Drawing.Rectangle ractagle = _screens[1].Bounds;
//player is  my window
player.WindowState = WindowState.Maximized;
player.WindowStyle = WindowStyle.None;

player.Left = ractagle.X;
player.Top = ractagle.Y;


// MediaControl is an media elements
MediaControl.Height = ractagle.Height;
MediaControl.Width = ractagle.Width;

But somehow it’s just playing on my first display. Any kind of help is very much appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
273 views
Welcome To Ask or Share your Answers For Others

1 Answer

You need to make sure that the WindowStartupLocation is set to Manual for the form you are displaying

Otherwise nothing you do will have any effect on the position of the window.

using System.Windows.Forms;
// reference System.Drawing
//

Screen s = Screen.AllScreens[1];

System.Drawing.Rectangle r  = s.WorkingArea;
Me.Top = r.Top;
Me.Left = r.Left;

This header of the XAML of the Window I used.

<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="823" WindowStartupLocation="Manual">
    <Canvas Width="743">
        //Controls etc
    </Canvas>
</Window>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...