How know number of monitor / screen on WPF as windows show on display settings

Viewed 153

Under wpf based on what I check, there is no way to pickup number of monitor where my app is opened. winform provide a method for discover this, but not works ok, winform method show number of monitor with no any correlation with what windows screen show.

enter image description here

The code I use is very simple, consist in add winform object can be any thing, then onload in wpf I just get the number of monitor in this way.

 numberofmonitor.Text = (Regex.Replace(System.Windows.Forms.Screen.FromControl(winformobj).DeviceName, "[^0-9]", "").ToString());


        <WindowsFormsHost Visibility="Hidden">
            <wf:MaskedTextBox x:Name="winformobj"  />
        </WindowsFormsHost>

This works, but this code just show the device name, not the monitor number. I search across the web and cant find any solution for get number of monitor with exact correlation windows display setup show. I search here on stackoverflow, but nothing I found works. This post can look like duplicated, but nothing I found here works under windows 10, I can get device numbers but not the number of monitor in correlation as windows shows. Some idea?

0 Answers
Related