Search code examples
wpfmultiple-monitors

wpf dual monitor application?


I'm very new to WPF. I want to create a dual monitor/projector application. What I want to do is have the "presenters screen" on one monitor and another panel on the secondary monitor, similar to how powerpoint works. I'm struggling to wrap my mind around the panels and XAML. So what I'm after is user clicks on a button on screen1 and information gets updated on screen2.

I'm using this code:

this.Width = System.Windows.SystemParameters.VirtualScreenWidth;
this.Height = System.Windows.SystemParameters.VirtualScreenHeight;
this.Top = 0;
this.Left = 0;

to set the width and height of the screen.

Edit:

The later goal is to cause screen2 to retrieve items out of a database based on the selection on screen1

Question: tutorials, places to go, nudges on how to update monitor2 from a button on monitor1


Solution

  • Short Answer

    Create a view model that shared between two views; make one of the views the master (makes the changes) and the other pure presentation. The views are new windows. Initially do not be concerned with the window position (we'll get to that later) just get the shared viewmodel working.

    Tip: research the MVVM pattern. Google has a lot of articles on the subject.

    Long Answer

    After you have researched MVVM and created a few example applications (from scatch or using a framework), below are few additional features you want implement to create the "powerpoint-like" application.

    • Fullscreen Mode

      At the very least you will want the presentation window to be full screen. To achieve this, you set the WindowStyle to None and AllowsTransparency to True.

      If you want to make the second window also fullscreen you may need to do some Win32 overrides to get the window to maximize properly without covering the taskbar (post a comment if you want to know how to do this).

    • Detect Multiple Monitors

      Get the size and position of the monitors using Win32 Interop commands. There will be plenty of articles on the Internet that will help you with this (or post another StackoverFlow question).

      This would be a neat™ feature as it will position the two windows correctly (use the secondary screen as the presentation).


    That is all that I can think of now, post-back if you any questions on MVVM or any of the additional points above.