Reputation: 918
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
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
Upvotes: 0
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:
<TargetPlatformVersion>8.0</TargetPlatformVersion>
line to the csproj fileSee above given link for details.
Upvotes: 2
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:
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