Can Windows.Devices.WiFi.WiFiAdapter API be used in a WPF desktop app

Jeff Nygren 121 Reputation points
2020-07-28T13:13:03.72+00:00

From my WPF desktop application, I need to list available WiFi access points, and monitor a WiFi connection.
Can this API provide the services I need?

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,682 questions
0 comments No comments
{count} votes

Accepted answer
  1. DaisyTian-1203 11,616 Reputation points
    2020-07-30T02:31:35.83+00:00

    Here is the step to use WiFiAdapter in my WPF (WPFCallUWPapi) project.
    Step 1. install the below package in the WPFCallUWPapi Nuget.[Microsoft.Windows.SDK.Contracts, System.Runtime.WindowsRuntime, System.Runtime.WindowsRuntime.xaml]
    Step 2. Add the Button to call the API.
    <Button Content="Call API" Name="Button" Padding="10" HorizontalAlignment="Center" VerticalAlignment="Center" Click="Button_Click"/>

    the code for Button_Click:(async is necessary):
    14419-2020-07-30-103033.jpg

    Step 3. Built annd run the WPFCallUWPapi

    Step 4. If you meet some error related Identity, you can try to create a Windows Application Packaging Project to make an Identity for WPF App. Mine name is WPFCallUWPapi.App , and it's target versions are all 1903. Set WPFCallUWPapi.App as Startup project.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. DaisyTian-1203 11,616 Reputation points
    2020-07-29T02:35:16.437+00:00

    Yes, it can. Windows.Devices.WiFi.WiFiAdapter API is in UWP , from the document we can see that it has DualApiPartition Attribute.

    APIs that have the DualApiPartition are supported in all desktop apps, including those with package identity and those without package identity.

    [Derive from APIs supported in all desktop applications].