I'm seeing lots of questions around the WinRT API mess, and lemme tell ya, you're not alone in the confusion. So, here’s my attempt at a super quick guide:
-
First things first, understand the app model. UWP apps run in a sandbox which means WinRT provides the APIs to access resources like files, network, devices, etc.
-
WinRT is based on COM; each API can be identified by a namespace which resembles .NET namespaces. For example, to interact with the file system, you're looking at
Windows.Storage. -
Make sure you're familiar with async patterns. A lot of WinRT APIs are async because they operate on I/O-bound operations. Get comfy with await/async patterns. If you're coming from a different platform, they might be a bit mind-bending at first, but trust me, they're your friend.
-
For your UI, you’re gonna wanna look into
Windows.UI.Xaml. It handles all your UI elements and rendering. -
Testing. Remember, the simulator is great for faking screen sizes/resolutions, but always test on an actual device!
-
And finally, keep up with the
Windows Community Toolkit. It's a gold mine of helpers and controls to make your life easier.
There you go! It's not exhaustive, but should get you steering the WinRT ship like a seasoned captain. Happy coding!
Spot on with the async advice! I'd like to add that when you're working with async in UWP, don't overlook the importance of handling exceptions properly. You'll save yourself a ton of headaches if you await your tasks correctly and Manage those exceptions that might bubble up from deep within the WinRT layers.