Hi,@MERUN KUMAR MAITY. Welcome to Microsoft Q&A.
If you want to use Windows.Devices.Display
and Windows.Devices.Enumeration
in WPF Application, you could modify TargetFramework
.
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
When you rebuild the project, you will find that Microsoft.Windows.SDK.NET.Ref
has been referenced
At this point, you could program the code to use
using Windows.Devices.Display;
using Windows.Devices.Enumeration;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Fun();
}
public async void Fun()
{
//Handle each display device
var displayDevices = await DeviceInformation.FindAllAsync(DisplayMonitor.GetDeviceSelector());
foreach (var device in displayDevices)
{
MessageBox.Show(device.Name);
}
}
}
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.