Contents tagged with UWP
-
Interesting Read: The future UWP
Morton Nielsen wrote an article called “The future UWP” about the situation for desktop UI development in the Microsoft technology stack which I found very interesting.
The main takeaways (not actually surprising):
- A lot is happening/changing/developing and it will take some time until the future really becomes clear.
- Quote: “Whether you do WPF, WinForms or UWP, if it works for you now, continue the course you’re on”
Personally, I’ll stay with WPF for my desktop UIs. When .NET Core 3 comes out, I’ll dip a toe into porting my applications.
-
Looking Back at 2018
The end of the year is typically a time to look back – here’s my personal list of programs and technologies that played an important role for me in 2018.
Visual Studio Code: It keeps getting better and better
This editor-becoming-an-IDE needs no introduction. I have included it in this list because 2018 was the year where I started doing meaningful work beyond editing HTML/[S]CSS files in Visual Studio Code.
For my purposes, it does not replace “classic” Visual Studio, but complements it. It’s not uncommon for me to debug ASP.NET Core and TypeScript code in Visual Studio Code as well as WPF code in Visual Studio 2018 at the same time (in a project where SignalR is used for Desktop Client <-> Server <-> Web Client communication).
I’m extremely impressed by the ecosystem of extensions (e.g. Live Sass Compiler, Live Server) as well as the ongoing development with its monthly releases.
Linea Sketch on iPad Pro: So good, it’s almost worth buying the hardware for
I love Linea Sketch, which is an iPad app for (as the name implies) sketching. When I tried out various graphics applications for my 2018 iPad Pro, I was looking for something that would allow me to quickly draw UI sketches and illustrations for presentations without much overhead. Linea Sketch caught my attention because of the combination of simplicity and power. Two highlight features of the app are “ZipLine” and “ZipShape”, which let you quickly draw straight lines, circles and polygons without breaking your flow of work with the pen.
Take a look at the Linea Sketch website to learn more about this fantastic app.
UWP: I wanted to like it, but what a disappointment…
I already wrote a bit about my frustration with the Universal Windows Platform (UWP) in the introduction to my previous blog post.
Obviously, each new platform comes with a learning curve. If you have a clear vision of what you want to develop and are learning how to do it along the way, you are bound to take longer than expected. What happened with UWP, though, was that I encountered problems that too often became roadblocks for hours or sometimes days. If you get silent crashes or low-level exceptions with an HRESULT that basically says, “something went wrong”, the only thing you can do is to comment out code you have just written up to a point where the program is working again. That reminded me very much of the early Silverlight days (version 2 and 3), Back then, error messages only became helpful in later versions (I remember version 4 and 5 as being good enough).
Web searches showed me that I wasn’t alone. Every so often, a question on a forum would made me go “yeah, I’d like to know an answer to that, too”. Unfortunately, often only reply would clearly indicate that the original post was only scanned for keywords, not actually read, let alone understood. Obviously, this is not a specific UWP problem. It’s just that other technologies seem to have reached a critical mass of users, so that e.g. on StackOverflow, additional comments and answers appear quicker and in larger numbers.
The final straw for me were silent crashes of the Windows App Cert Kit, which had worked on my machine earlier. Searching for a solution, I came across Microsoft forum threads reporting WACK problems that went on for months, with no real solution in sight.
I don’t know whether the WACK problem has been solved now, or whether UWP in general has become friendlier in terms of developer experience. But frankly, I have stopped caring. After all, we’re talking about programming as a hobby. Maybe I’ll revisit UWP in a few years – but for now, I have moved on.
And by the way: I actually do like UWP APIs. They make e.g. creating a thumbnail of a media file or determining the length of a video file super-easy. But I can use these APIs from a WPF program as well, so that’s exactly what I’m doing now.
ASP.NET Core (Web API, SignalR): A positive surprise
While working with UWP was hard work for every step along the path, ASP.NET Core was clearly the opposite experience for me. Whenever I ran into a problem, I found a sample or some forum or StackOverflow post that helped me find a solution. And unlike with UWP, where I came from a WPF and Silverlight background, I didn’t have much prior knowledge.
To put things in perspective:
- I started with version 2.1, i.e. I surely skipped a lot of the problems of the 1.x days.
- I found a great starting point with the SignalR with TypeScript and WebPack sample.
- I use ASP.NET for non-UI, server-related functionality that is limited in scope.
So, your mileage may vary. For me, the positive initial experience was a great motivation to learn more about the platform and to overcome the small problems that are simply a natural part of software development.
-
Microsoft Design Resources
The Microsoft Design team offers developers and designers guidance on the design of app user interfaces on various channels:
DevCenter (Design Section)
The Windows DevCenter has a section dedicated to the design and UI for UWP apps, with information on style, motion, layout, interactions and more.
Medium
On Medium, the Microsoft Design team publishes articles more or less each month.
Dribble
Dribble is “a community of designers sharing screenshots of their work, process and projects”. Individual Microsoft designers have been on Dribble before, but now there’s one Microsoft account showcasing all the work in one place.
Twitter
Following Microsoft Design’s twitter account doesn’t hurt – it is active, but not too much, with a post every couple of days.
-
MarkdownTextBlock Improvements in UWP Community Toolkit 1.4
Version 1.4 of the UWP Community Toolkit has been released, read more about it on the Windows Developer website and in the release notes.
In my blog post about version 1.3, I wrote about the then-new the MarkdownTextBlock control which had a couple of missing features. While writing the blog post, improvements were announced for 1.4 on the Universal Windows Platform UserVoice page and I can now confirm that they are actually in the new release:
- Images are supported (They cannot be embedded inside a hyperlink, though).
- Triple backticks (```) for fenced code blocks are included (without language-specific syntax highlighting, which frankly would be a bit too much to ask – but a way to implement your own would be nice).
- Tables work as expected.
The fastest way to try out the MarkdownTextBlock (and many others controls and features) is in the UWP Community Toolkit Sample App in the Windows Store.
-
UWP Community Toolkit 1.3 Released – now with Markdown
A new version of the UWP Community Toolkit has been released, this article on the Windows Developer website has the details on what’s new.
One thing that caught my eye was the MarkdownTextBlock XAML Control that does exactly what the name implies: You set the
Text
-property with some Markdown text and it shows the rendered Markdown. You can change the styling of the output (font size, color, etc.) to match your application or a specific desired document style. And theLinkClicked
event tells you when a link has been clicked.If you want to see it (and all the other toolkit features) in action, download the UWP Community Toolkit Sample App in the Windows Store.
How good is it?
If you’ve used Markdown in more than one application or website before, you’ll know that there are smaller and larger differences here and there (the website for CommonMark has more on that).
Playing around with the control to learn more, I found the following:
- The basic features (headings, bold, italic, bulleted lists) work as expected.
- Inline HTML is not supported (understandable when rendering Markdown outside a browser)
- Images are not supported – yet; they will be in version 1.4.
- Tables (which are not part of the original Markdown description, by the way) don’t work. Interesting that the Markdown text in the demo app contains a non-working sample for a table. This will be fixed in version 1.4.
- Another Markdown extension missing are (GFM style) fenced code blocks using triple backticks – they will be added in version 1.4, but don’t expect language-specific syntax highlighting.
While this list makes it sound like there are a lot of things that aren’t working (yet) or are missing, it is important to consider use cases for the control.
- Do you plan to display arbitrary Markdown like Readme.md files from GitHub?
- Or do your want a control to display explanation texts on a form (where you write all the markdown)?
If the latter is the case, the control most likely will do its job already in version 1.3, with the tables and images coming in version 1.4 being a welcome addition, of course.
-
UWP Community Toolkit 1.1 Released
Back in August I blogged about How to Search Twitter from Your UWP App using the then-new UWP Community Toolkit. Of course, the toolkit offers much more than that. It has now been updated to version 1.1, with quite a list of improvements and fixes. A small, but nice addition is the GridSplitter, which was one of the first things I was missing when moving from WPF to UWP.
The release also sends a strong signal about the future of the UWP Community Toolkit. It is now part of the .NET Foundation (which brings a move of the documentation to a new location) and has promising community activity. While this may not be a guarantee for longevity, at least the signs point into the right direction.
-
How to Disable Warnings in Generated C# Files of UWP Apps
The first time I moved my UWP development beyond writing “throwaway code for learning purposes”, I did what I always do when starting a new “real” project: On the “Build” tab of the project properties, I switched the setting “Treat warnings as errors” to “All” and set the checkmark at “XML documentation file”.
Nasty surprise: When compiling the UWP app, the compiler stumbled over missing XML doc comments in code that was generated in the background.
Fortunately, I quickly found a solution on StackOverflow that automatically added a
#pragma warning disabled
to the generated files using MSBuild. That worked well for me until recently, when I created a new solution configuration that had a name containing spaces. Digging a bit into MSBuild, and with the help of another StackOverflow answer, I was able to figure out the following build target (which I’ll add as an answer to the original StackOverflow question):<Target Name="PragmaWarningDisablePrefixer" AfterTargets="MarkupCompilePass2"> <ItemGroup> <GeneratedCSFiles Include="**\*.g.cs;**\*.g.i.cs" /> </ItemGroup> <Message Text="CSFiles: @(GeneratedCSFiles->'"%(Identity)"')" /> <Exec Command="for %%f in (@(GeneratedCSFiles->'"%(Identity)"')) do echo #pragma warning disable > %%f.temp && type %%f >> %%f.temp && move /y %%f.temp %%f" /> </Target>
How to use this:
- Unload and edit your “.csproj” file in Visual Studio (or open it in Notepad if Visual Studio is closed)
- Copy-and-paste the task just before the closing
</Project>
tag - Save and (re)open in Visual Studio
-
How to Search Twitter from Your UWP App
Yesterday, the UWP Community Toolkit was released, “a new project that enables the developer community to collaborate and contribute new capabilities on top of the SDK.”. The toolkit “includes new capabilities (helper functions, custom controls and app services) that simplify or demonstrate common developer tasks”.
One thing that caught my eye was the support for social media like Twitter and Facebook. I had read the docs at https://dev.twitter.com/ and I had a twitter app configured at https://apps.twitter.com/ some months ago, but I never got around to actually choose a Twitter access library and use it.
But the few lines of sample code in the announcement (how to post a tweet) looked so simple I couldn’t resist trying to perform a Twitter search.
- Follow the “Getting Started” instructions in the article. (I chose the packages Microsoft.Toolkit.Uwp and Microsoft.Toolkit.Uwp.Services)
-
Put a button on the form, create a click handler with the following code:
private async void HandleButtonClick(object sender, RoutedEventArgs e) { TwitterService.Instance.Initialize( // change (1) - (3) for your app "(1) ConsumerKey", "(2) ConsumerSecret", "(3) CallbackUri"); await TwitterService.Instance.LoginAsync(); tweets = await TwitterService.Instance.SearchAsync("hello world"); foreach (var tweet in tweets) { Debug.WriteLine(tweet.Text); } }
- And that’s all it is to search Twitter for e.g. “hello world”!
Things to note:
- Even though the API is really easy, it doesn’t mean that you can avoid reading or at least scanning the Twitter documentation altogether – you need to know just enough the get the required information for login.
- Storing the ConsumerKey and ConsumerSecret in an app as plain text doesn’t sound like a good idea – I’ll have to read up on what best practices are in regard to security.
-
My UWP Link List
I’m still at the beginning of my journey into the world of Universal Windows Platform (UWP) apps. In this blog post (which will be updated over time) I’ll collect various links to resources I found interesting and/or helpful – maybe they are of use for other people, too.
Basics
- The Windows Dev Center (dev.windows.com) is the starting point for Windows development. Documentation, downloads, samples – it’s here.
- Get started with Windows apps contains everything to, well, get started. I doubt you’ll find a more clear and concise information about how to do it than this page and its sub-pages (in the past, people actually made it their job to extract information out of wordy Microsoft articles).
- Back in the Windows 8.x days, side-loading didn’t sound too attractive. Much has changed in Windows 10 and this article sums it up: Sideload LOB apps in Windows 10
- And things are looking to get even better soon: App Installer! (via Universal Windows App Deployment blog)
- I wanted a code-signing certificate (not only for my future UWP apps), in the end I chose KSoftware who are an official partner of Comodo.
Debugging
Resources
General
- Blog: Building Apps for Windows (by the Windows Apps Team)
- Article: The Lifecycle of a UWP App
- Article: The path from a desktop app to a Universal Windows Platform (UWP) app
- Article: Optimizing your XAML app for performance (10 by 10)
- Website: Develop UWP apps – How-to articles for UWP apps on Windows 10 (“Instructions and code examples for all kinds of tasks, such as using geolocation services, transferring data over a network, and porting apps to Windows 10”)
Architecture
- Template 10 is a set of Visual Studio project templates that take care of boilerplate stuff like navigation and suspension
- Visual Studio Extension: Template 10 Template Pack
- Wiki: Documentation
- Video: Getting Started with Template 10 (on Microsoft Virtual Academy)
App Services
App Services are a very interesting concept for UWP applications that are more than just a simple self-contained “app”.
- Create and consume an app service
- Convert an app service to run in the same process as its provider
- Calling an App Service from a WPF/WinForms Win32 App
- Launch a Universal App from a WPF App contains the important part of how to reference Windows 10 APIs. When copying the XML code snippet in the blog post, leave out the reference to System.Runtime.dll and make sure you replace the typographical quotes (
“example”
) with plain quotes ("example"
).
App Services in a Network
Personal Interests
My main motivation to start with UWP apps is to use the graphics and video capabilities that look much more attractive than what WPF has to offer.
Graphics and Animations
- Blog: robmikh blog (“A development blog about all things UWP and Composition”)
- Blog: Mike Taulty (“I do some developer stuff for Microsoft UK”)
- Articles on composition: https://mtaulty.com/category/composition/
- Articles on Win2D: https://mtaulty.com/category/win2d/
- Article: Windows 10 Anniversary Update–Fun with Composition and Video
- Website: Windows UI Dev Labs on github (“the place for getting the latest code samples and demos using Windows.UI.Xaml and Windows.UI.Composition to make beautiful Universal Windows Platform applications”)
- Article: How to prevent screen locks in your UWP apps
- Article: Creating a FluidBanner control using Windows Composition
- Library: CompositionProToolkit on github (“Collection of Helper classes and controls (using Win2d) for Windows.UI.Composition”)
MediaPlayer
- API reference
- Article on Windows Dev Center
- Video Shenanigins (article by Make Taulty)
Troubleshooting
Solutions for issues I ran into:
- How to disable “Missing XML comment” warning for auto generated code in Windows Store app? (StackOverflow)
-
Nice Time Saver: Windows Universal App Image Scaler
Recently I took my first steps into the world of Universal Windows Platform (UWP) apps after many years of WPF. What came a bit as a shock to me was the sheer number of required/recommended tile and icon assets.
Most of the images are versions of the same image, scaled to different sizes. Of course, creating these images is something that can and should be automated, starting from a sufficiently large image.
One way to handle this is via Photoshop Actions, but when looking for a simpler solution I came across the Windows Universal App Image Scaler. This is a Visual Studio extension that adds a context menu entry to the Solution Explorer. You simply right-click an image file, choose “Scale image for Windows Universal app…” and specify the kind of images you want to create. When you press “Ok”, the output will be written to the directory that contains the source image, and that’s it!
You find this nice extension
- in the “Extensions and Updates” dialog inside Visual Studio (via the “Tools” menu) by clicking “Online”, “Visual Studio Gallery” and searching for “app image scaler”,
- on the Visual Studio Gallery website: https://visualstudiogallery.msdn.microsoft.com/824f5375-b0c7-4d79-b9bf-04653876ba53
- or on GitHub: https://github.com/spadapet/universal-image-scaler