Frank im Wald
Frank im Wald

Reputation: 918

Proximity tap in WPF

I'm trying to detect nearby devices using NFC or RFID from within a WPF application.

Microsoft's proximity API seems to be the right way to go: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh465221.aspx

Unfortunately, I see no way to get it running inside a WPF application (or any other Desktop Technology that is). All examples refer to Microsoft store apps only.

From within a WPF application I cannot reference the Namespace

using Windows.Networking.Proximity;

Is it just a reference that I am missing? Is it possible to use the proximity API from a WPF application at all?

Upvotes: 2

Views: 2316

Answers (3)

Nabster
Nabster

Reputation: 1227

[2020 is here]

Procedure to prepare your Console/WPF project to call UWP APIs (both are OK):

Heads up: You'll need to migrate the project from the packages.config management format to the PackageReference format

https://learn.microsoft.com/en-us/nuget/consume-packages/migrate-packages-config-to-package-reference#migration-steps

Upvotes: 0

Frank im Wald
Frank im Wald

Reputation: 918

I finally found a sample project using the proximity API from within a WPF application: http://code.msdn.microsoft.com/windowsdesktop/NFC-Editor-529ccda6

There is also a short tutorial included on how to use WinRT API's in WPF applications.

The basic steps:

  • Manually add a <TargetPlatformVersion>8.0</TargetPlatformVersion> line to the csproj file
  • Back in Visual Studio, add a reference to Windows/Core/Windows to the project references
  • Add a reference to the Windows Runtime assemblies to the project.

See above given link for details.

Upvotes: 2

Sheridan
Sheridan

Reputation: 69979

I believe that the Windows.Networking.Proximity.ProximityDevice class is not available in WPF Applications. If you look on the ProximityDevice class page on MSDN, you'll see that it is part of the Windows.Phone API:

enter image description here

The monitor image next to the phone image also leads me to believe that it is available for Windows Store Apps too. I'm guessing that (at present at least) the vast majority of desktop computers won't have any RFC hardware that could be used with this code and so that is why it is missing from the standard .NET dlls.

Upvotes: 1

Related Questions