Is it possible to use UWP APIs in a WPF app? - c#

One example would be the new notification APIs for Windows 10 universal platform. Can I use this set of APIs in a WPF app? If so are there any limitations?
Links to documentation regarding this would be much appreciated.

It is possible to use UWP APIs in a WPF app. However not all UWP APIs can be used in a WPF app.
There are exceptions to the rule that Windows 10 APIs are accessible from PC software. The first big exception concerns XAML UI APIs. The XAML framework in UWP is different from the one in WPF and you really don’t want to be mixing them up, anyways.
The second set of APIs that you can’t use are ones that depend on an app’s package identity. UWP apps have package identities while PC software does not. Package identity information can be found in the app manifest file.
How do you determine which Windows 10 APIs require a package identity and which do not? The easiest way is to refer to this MSDN topic.
For how to access the Windows 10 APIs from WPF, please refer to this answer and also see the blog Calling Windows 10 APIs From a Desktop Application (Please note the name of the references in the blog is not right, so I'd suggest you refer the answer in SO).

No, You can't - at least for now -
But there's a progress on a project called "Centennial" Which will enable you to do so.
More see "bridges".
Yes, you can now.
https://blogs.windows.com/buildingapps/2017/01/25/calling-windows-10-apis-desktop-application/

Related

Is it possible to run a .Net UWP Class Library on Azure?

I thought up an idea for a website that would involve some video editing happening on the web server. Microsoft UWP has a library that does the video editing functions I'm looking to perform... Amazing!!
My problem is I don't know if it's possible to get my website to run UWP code on Azure. Web Jobs seem like what I'd prefer to use to kick off this code, but web jobs don't appear to be able to run UWP code and without UWP code I don't see a library that can perform the video editing I'd like to do. Does anybody know if it's possible to run UWP code on Azure? If so, how?
I don't think WebJobs are especially suited for this scenario. They are part of the WebApp platform as a service offering that abstracts the underlying operating system for you to be able to focus on building the code itself and deploy as easily as possible.
UWP on the other hand is a Windows-specific app platform which has many requirements including running on Windows 10. Because you don't know which concrete operating system the web app will run on, it is not easy to say if the APIs would work.
That said, you could theoretically use UWP APIs in a web app as well, because there is a UwpDesktop NuGet package that allows it mainly targeted for desktop apps. It is a long shot but you can certainly try it.
As a preferable solution, I would still look to find another library that suits your needs, as the choice on NuGet is pretty broad and one of those should be sufficient.
I would suggest taking a look at azure functions
These have about the same working as webjobs, however expand beyond the limitations of webjobs. These are also more versatile in what they can do and how they can be created.
webjobs vs functions

Using Universal Windows Platform (Windows 10) controls in WPF

Hopefully a simple question; I seem to recall seeing somebody at one of the recent Microsoft conferences say that some of the UWP application functionality was to be made available within WPF/Desktop. Unfortunately, I can no longer find (or remember) which of the many videos this was from (though it was probably Build or similar on Channel9).
Is it therefore possible to use UWP controls within a WPF application? Basically I want the look and feel of an "app", including some of the new controls (RelativePanel, SplitPanel) and the themed buttons etc., but I need the power of the full desktop - such as access to the full file system.
Thanks.
I think you are referring to the different Bridges to port apps to Windows 10 from for instance, IOS, Android, Web, Win32, etc. and still take advantage of Windows 10 features and APIs. Specifically, I think you are talking about the Bridge to bring in Win32 apps. You can find the bridges listed here.
https://dev.windows.com/en-us/bridges
•"Project Centennial": This toolkit will enable desktop developers to package and publish their existing .NET and Win32-based Windows applications to the Windows Store. Developers can also use Centennial to call common UWP APIs and services."

Windows Store 8.1 and System.Windows.Forms

Recently, I tried to make a battery app (C#, store app) for Windows 8.1
(I am using VS2013, tried also VS2012 with the same result).
As it turned out, I need to add a Reference to the project - but I cannot add anything in Reference Manager: it says "All of the Framework assemblies are already referenced". And all what I need is to get System.Windows.Forms - when I search for it, nothing appears.
Any ideas, what can I do?
(Please tell me if I forgot something essential)
Windows Store Apps are build, from scratch, on new technology stack , So Windows Form and WPF are not part of Windows Store apps.
Windows store apps and Windows Forms apps has there different set of
APIs.
Windows store apps are used to known as known as Metro apps and Right now they have been merging the stuff(don't want to go into the details).
This will give a basic knowledge about this new Technology
So, above are the just a small hints about the differences. Actually, It is not possible to explain all the stuff here. Just explore.

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?
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.
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.
[2020 is here]
Procedure to prepare your Console/WPF project to call UWP APIs (both are OK):
https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-enhance
https://blogs.windows.com/windowsdeveloper/2019/09/30/windows-10-winrt-api-packs-released/
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

How to port existing Windows Store Application to Windows8 Mobile App ?

We have existing Windows Store application which is developed using C# and XAML. We want to port the same to Windows 8 Mobile application. Is there any Guidelines available for this ?
Well at first I would start figuring out the differences
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj681690%28v=vs.105%29.aspx
http://blog.markedup.com/2013/07/winrt-windows-phone-8-code-sharing-pitfalls/
When I ported two of my (smaller) apps, I put as much in a PCL (portable class library) as I could. All the stuff that remained in the project itself needed to be rewritten. If you have well-maintainable code, there should be only UI (what you have to adapt anyway) and very few platform specific code (like accessing filesystem, camera or whatever) left. This is the part you must redevelop.
Dnt know how you have made these applications well If you have followed MVVM pattern then it is very easy to port windows and windows phone apps from one to other. You just need to take care of new XAML UIs every thing except some platform specific liberalizes will work. While making any of windows store and windows phone application you should use the liberaries that both platforms can consume. For example you can use LEX.db for the database.
here are very good explanations for it.
sharing code between windows phone and windows 8 app -1
sharing code between windows phone and windows 8 app -2
hope this will help
The answers given so far are quite good. One thing to note is that Windows Phone 8.1 is about to be released, which will share many of the WinRT libraries. This will mean that in a few months (as early as May), the shared libraries between the two platforms will greatly increase. You can download the leaked SDK to see what some of the changes will be.
Not that you should wait until then, and creating a PCL is definitely going to help you (especially if you want to later move to iOS, Android as well). It's just something to keep in mind.

Categories