WinUI, The modern native UI platform of Windows
microsoft.github.io
microsoft.github.io
I think Microsoft knows it needs (1) a way for developers to build apps that look like they belong in 2020 (2) where the frameworks won’t find themselves in the garbage within a few years. This “toolkit approach” seems to recognize that the runtime is a separate problem, so e.g. you can use Win32 + C++ + WinUI, or you can use C# + UWP + WinUI and get something reasonably consistent.
Maybe this is the time Microsoft gets it right. Who knows?
Windows GUI was done right long time ago by Delphi and now Lazarus. Now it is also multiplatform. When it comes to UI with Delphi approach I could concentrate on what I am doing instead of how. And it's been available for 25 years.
C++/CX seemed to finally be what I was expecting, since C++/CLI never had designer tooling support.
But since they got the ISO C++ striking force to redo C++/CX with C++17, now we are supposed to wait for ISO C++23, for the Visual Studio team deliver with C++/Winrt what C++/CX can already offer today.
Sometimes I think someone should offer some C++ Builder licenses to Visual C++ team.
The auditorium exploded in laughing.
3-4 years down the line, that "biggest thing since sliced bread in development for Windows, and WinMo" got quietly swept under the carpet.
And even after that, they tried to spin 3 or more "trendy Javascript platforms" to no avail.
So now they have 6, possibly 7 defunct Javascript platforms for Windows whose very fact of existence completely discredits them in eyes of developers.
P.S. He forgot to mention Windows script hosts!
But what about their ReactXP? That's supposed to let you build for React for Windows & Mac and thus WinUI, and also React Native for mobile and such.
Unfortunately, development on it has slowed and it's not the easiest experience for new developers.
Fortunately, it's super flexible and open-source so I've forked it to continue my vision of the perfect native cross-platform stack:
It's a pretty mature project so there's not many changes needed.
The main thing was I wanted it to do more and I didn't agree with certain styles and APIs.
No benchmark is needed. Running your app in an entire browser (one of the most complex pieces of software w/ millions of lines of code) is of course going to be less performant and eat more resources.
I'm not dissing Electron, it's great if you have a web app that you want to make standalone on the desktop. That alone does not make cross-platform though.
Ult can target the DOM so you can build a web app then wrap it with Electron. This is currently the best way to target Linux. Ideally there will be a GTK bridge like the bridges for the other major desktop and mobile OSes.
Wow. This reminds me of the stupid prediction I made in another thread today about Microsoft eventually abstracting Windows away so that it's a shell that can run on top of Linux. Or perhaps any other kernel.
In what ways grid and stackpanel are broken? They seem to perform exactly as designed (though I only have CSS to compare to, but it is magnitudes worse).
The fact, that core controls have no default spacing seems like a sane engineering decision, considering you can set it app-wide with a few lines of XAML.
Shortcuts sound like a problem for a specific scenario. The default binding update on lost focus might have been a bad decision, but even given my little experience I remember it quite well.
- it can't be solved with DockPanel (which is OK.) - it can't be solved with hbox(StackPanel), because of StackPanel's broken design (ie not handling resizing children.) - so I'm forced to use Grid.. Which, for this trivial task, requires this:
<Grid Margin="0,10,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
And then, on each of my 4 children, I have to put these:
..Grid.Column="1" Grid.Row="1"What a bloated inelegant mess. I don't want to specify absolute indices on my grid children, I want it handled by nesting or symbolic row identifiers (anything where I don't have to count/update row/column indices by hand.)
I'm not happy, that the layout rules for grids have their own "", "number", "number", "number%" system independent of the hor/vert alignment system. I don't want to specify an absolute height on my label row.
When I look for solutions to that, I end up with useless "guides" like this: https://www.wpf-tutorial.com/styles/using-styles/
StackPanel: It assumes children have known static sizes. You can't specify "2 children with 50% space each". Thus a downgrade from hbox/vbox layouts we've had since 1989 :-(. Because of this, most of my layouts are a weird mix of DockPanel, StackPanel and Grid (not because I want DockPanel, but because it's less broken than the other two.)
How would you set up default spacing/margins app-wide? I can't see how you would do that, without at the same time adhering to some custom "magic" rules, in your xaml instances, to cooperate with your app-wide settings? IE normally you end up with weird mix of "margin at 10px", but then have 0 margin on some sides, for first/last item.
Shortcuts are not a "specific scenario". The shortcut in question is closing a dialog, where your OK button has IsDefault="True". In that case, the value in user's current edit field is not transferred, unless you as a programmer address it. Apple had this issue handled in 1994 :-/. Microsoft in 2007 believes programmers love dealing with stuff like that.(e.g. UpdateSourceTrigger=OnPropertyChanged will solve some cases.. Hooray, I really love having to type UpdateSourceTrigger=OnPropertyChanged.. Well no I don't).
I'm not asking for fixed default spacings, I'm asking for a well-designed mechanism to handle margins and spacing, app-wide, without having to specify alternating "0 pixels above, 10 pixels below" on random buttons to make things fit.
An funny example is StackPanel missing an items-Spacing property. The funny thing is, it actually has this setting.. But it was only added in 2017 (after 10+ years?), and available in some SDK preview that I have never managed to find in either my VS2017 or VS2019.
I forgot to mention ways in which DataGrid is broken. On paper, it seems great. But in practice, the implementation of things like DataGridComboBoxColumn means it only works for toy examples. If your tables have 20 rows and 3 columns, DataGrid with DataGridComboBoxColumn seems fantastic. But we don't have 20 rows and 3 columns, do we? No wait, we have 30-40 columns, and 900 rows.. And then you find out that DataGridComboBoxColumn performs like a dead dog/kicking a whale down the beach, because some genius at microsoft thought it a good idea to look up the display value for each cell dynamically in the combobox itemsSource, FOR EACH CELL IT HAS TO RENDER.
And then you get a head-ache, because you remember programming the same things back in 1995 and 2003 and 2007 and 2009 with Qt/MFC/Delphi/Swing(yes, swing..), and having them perform well, and wonder why this is suddenly not possible in 2020. There are solutions to many of the problems in 3rd-party, e.g. Caliburn, but I don't want to have to use 3rd-party fixes for things that should be in the core package, in 2020 (and 2007, or whenever they did WPF.)
Another thing: WPF not throwing exceptions (or silently catching them, whatever you call it.) I'm very much not a fan of this. As far as I can see, it just means programmers are ignoring and/or inaware of and not fixing, a million bugs in their GUI code. If you don't believe me, try running Autodesk's monopoly building design tool Revit. Parts of it is written in WPF. You can tell that, because if you run Revit from within Visual Studio, the Immediate diagnostics Window is scrolling full with all the errors that Autodesk's programmers choose to ignore. Which is real helpful, when you are trying to find the messages YOUR program outputs in the same window :-/.
I had the pleasure to work it during 5 years.
Qt is also no walk into the park with multiple iterations of the UI scripting language, unclear roadmap of QML vs C++ based widgets, bugs left years unfixed for mobile platforms since they decided to pivot into IoT (aka Devices), the whole non standard C++ macros, and several other issues.
I am NOT developing the same GUI N times for N different platforms. No way. Even very large companies like Slack are refusing to do that. They have the resources to have three or four parallel dev teams but why?
I don't care how nifty, pretty, fast, or modern this new UI is. It's not cross platform therefore it does not exist.
This is not a technical problem. Check this project out:
https://github.com/andlabs/libui
Yes it's minimal and rough around the edges, but it's the work of one developer in their spare time. If one developer hacking away in the evenings can do that, then there is no excuse.
If OS vendors keep insisting on being special and trying to herd developers into making OS-specific apps, developers will keep going to bloated but portable alternatives like Electron and Qt. Why is every new app an Electron app? Don't blame developers or Electron. Blame OS vendors.
It's 2020. We have common portable APIs for threads, networking, even 3D graphics, but not 2D GUIs. It's easier to write a portable cross platform 3D rendering engine than it is to write a portable cross platform app with a menu, a box, and a button. It's just offensive at this point.
IMHO there are many things to dislike about 'modern' GUIs!
Back when Windows was a relatively new concept common sense things like making buttons stand out and using colour and borders to group and organize features. These things have pretty much gone out the window. Everything is a flat homogeneous dark scene.
/rant
If I'm on a desktop, then I use the mousewheel for incremental scrolling and home/end/page/up/down for faster scrolling.
If you have a long page and your looking for something "about this far down the page", there should be a TOC or a map.
On touch interfaces, it's just the side of the screen or standard scroll.
At this point, for me, a scroll bar is more an read only position indicator than an actual navigation tool.
Interested to see if I'm in a minority here.
I love my little HP plastic laptop. It's a plastic toy I got for $85, including a Windows 10 Pro license, and I just toss it into my bag when I want to go somewhere. Perfectly adequate for text editing. Yesterday I had Visual Studio Code, web browser with 10 tabs, Ubuntu 19.10 via WSL, and Docker desktop all shambling along. I felt like Jason Bourne driving an attack Lada.
My other Win10 device is a ThinkPad x230. Its touchpad is also limited, but has three real hardware buttons.
Mostly I use similar aged MacBook Pro or iMac with Magic Touchpad. Totally different level of quality, no comparison really.
I always wondered why pro Windows laptop users in my family only used extra USB mouse devices. Ugh. I have yet to experience a mass market Windows laptop trackpad that most people would be able to use full time.
It comes in quite useful when I need to move over a lot of space to find what I'm after. I'd be using the wheel on my mouse for quite some time otherwise.
Yes, all the time.
Seriously annoying.
This has actual technical details, the roadmap, the rationale, etc.
To those wondering: this does not offer cross-platform GUI. Microsoft’s (inadequate) answer to that is blazor in browsers or browser controls. When they say cross-platform support for WinUI they mean it can be targeted by libraries providing cross-platform UI abstractions, the example they give is react native.
They've also have been the ones leading the effort to add MacOS support to react-native.
To write a RN extension for X platform you will write it in the language for that platform.
To use a RN extension you can use any ECMAScript language.
- Windows shop deeply invested in C++ and wants to go cross platform? => React Native (playing the role of Microsoft's QML)
- Windows shop deeply invested in .NET and wants to go cross platform? => Xamarin
This is like yet another messaging app from Google.
qt now also supports python as a first class citizen (https://www.qt.io/qt-for-python). The documentation is still a little bit lackluster but it largely mirrors the c++ api.
I've written a few smallish projects with it and it's been a breeze.
Bindings are available for Python, Go, Rust, C#, Java, Crystal, D, Haskell, Julia, Node.js, OCaml, and more besides:
https://wiki.qt.io/Language_Bindings#These_are_third_party_l... (non-exhaustive)
It's not C++ and it works in-place, but my manpages say "strtok" has been standardized since C89. strtok_r in POSIX since 2001.
Tells you everything you need to know about how excited Windows developers are about yet-another half-baked UI framework that will likely never get critical, required features before it is abandoned.
[1] https://marketplace.visualstudio.com/items?itemName=Microsof...
Yes, Electron requires more resources than native apps, but that's only a problem if you're making a trivial app such as a calculator. If you're building a substantial app then the fact that Electron apps require more memory is usually not a problem. And that's the reason Microsoft themselves uses Electron for Teams, VSCode etc.
> Yes, Electron requires more resources than native apps
It requires orders of magnitude more resources. Many of us are sick of watching huge chunks of expensive computers' ample resources go to waste so that some startup dweeb can avoid hiring actual desktop development people. It is the #1 harbinger of the kind of resource inflation and lack of engineering excellence that keeps people having to buy new hardware unnecessarily, but hey who cares BeCaUsE mAh BaLaNcE sHeEtS
Not many enough to matter.
> who cares BeCaUsE mAh BaLaNcE sHeEtS
It is an actual concrete fact that in many (most?) cases the total cost of developing and owning an Electron-powered app is going to be lower than a real native desktop application given that you can reuse the same code/people/skills you already employ on your website and mobile app. Building the same UI n times is crazy.
Are you just complaining about that fact or actually suggesting that we ignore it and stand up against "resource inflation" as a matter of principle? I can't imagine a startup CEO going before their board with a slide deck and saying "We're making progress on a unified app experience across web and mobile that should reduce our development costs. We were going to do the same thing for desktop too, but then we realized that Engineering Excellence™ meant we had to hire a whole new team of developers. No, the app isn't performance constrained, why do you ask? Sure, everyone else is using Electron but everyone else is wrong."
Gonna need a citation on that. Every tab of Gmail I have open takes up more RAM than my fully-featured Outlook desktop app that's pushing an order of magnitude more items through Exchange.
Slack, Discord, and Teams are loads more heavyweight than all the fanciest (non-Electron) IRC clients. Or look at Telegram: wicked fast native client that's barely using more than 100 MBs on my box with 20 some odd group chats all pushing instant multimedia notifications every couple mins.
Not to mention all the Electron counterparts are just slower. I actually don't know what black magic Microsoft did to make VS Code so snappy (it's way more responsive than all those chat apps I listed above), but it's also still noticeably laggier than Sublime and true Vim.
So I mean, "it's usually not a problem" is true, resource consumption of the clients don't appear to affect acquisition of users or popularity of the platform.
I don't think it's a stretch to assume that there's some non-zero set of folks out there that tried to switch from Exchange/Outlook to Slack at scale and said "this doesn't really meet our needs". Some of that is UX, sure, but that UX was also driven by the limitations of performance.
How big is that non-zero set? Who's to say, business is hard and full of imperfect assumptions. But I can tell you as a user of most of these apps, having them not do what I tell them to do because of laggy UIs is infuriating. (E.g. I constantly make the mistake of "reacting" to someone else's message in Teams while I'm trying to find a permalink or edit my own message. Then they get a push notification, I erase the reaction, and I hope they assume it was a mistake. Happens every couple days.)
This means that you can use WinUI from C++ code, or from C# code, or from .... code, rather than having to choose (and learn) a UI toolkit for each development environment.
Whether it will actually play out that way, who knows.
Also, fool me once...
To be fair, their past offerings still work fine, they're just in maintenance mode. Which is exactly what a lot of people want- they stop changing and everything you built with them just keeps working.
I work on an application that targets both windows and mac. we have windows UI code that was written ten years ago that still works and looks more or less okay. on the other hand, every year we have to deal with breaking changes and new bugs from framework updates on the mac side.
It's not like what's expected out of desktop GUIs have been completely static over this time frame.
I wonder if WinUI is truly more performant than Winforms. Winforms hooks directly into WINAPI. How can you be faster than that ?
Does this mean this can be used to create Desktop applications that work on Linux & OS X?
https://www.paulgriffiths.net/program/c/srcs/winhellosrc.htm...
wndclass.cbSize = sizeof(wndclass);
why does a struct need to be told its own size?Inside the implementation of the API they might say:
if (wndClass->cbSize == SIZE_IN_PREVIOUS_SDK_VERSION)
{
// Code to handle legacy structure goes here
}
If they add to the struct and don't make accesses to the new members conditional on cbSize's value, then it's a bad pointer dereference. The caller allocated it with the "old" size, likely on their stack, and some unrelated value might be located where the new members would be, or it could be a bad pointer.I do believe there's a good reason; I just can't figure out what it is.
edit for any curious readers: I found an answer here https://stackoverflow.com/questions/30416191/why-do-some-win...
Telemetry to help your own products or Microsoft?
At least they got rid of that buggy crash-prone Blend designer (that wasn't truly WYSIWYG) and the idea of using DI for design-time data instead of just doing hot-reloading during runtime (which I believe they finally embraced, after AmmyUI showed the way).
(one difference is that the WCT is mostly C# and WinUI/the built-in controls are C++)
Then, in 2000, Microsoft gave us .NET and WinForms, and we all thought that we'd be cross-compiling our C++ apps so that they ran inside of the hybrid native/.NET compiler called C++/CLR, so that we could take advantage of this improved UI toolkit. From C#, WinForms worked great. From C++, not so. But we thought that maybe we could write our GUI in C#, and interface to C++ for the heavy lifting/legacy code. I tried it a bit, and it was doable, but it ended up being very clunky to have this giant divide between the .NET world and the native C++ world.
Fast forward a couple of years, and Microsoft started talking up XAML, and it's native Windows Desktop incarnation called WPF. It had a browser sibling, which was Silverlight. This was a completely different to WinForms, and it was the future of Windows UIs. I tried it a bit. It made your app startup slowly, because it was now a .NET app. There were some interop issues between plain old C++ code, and C++/CLR, but it was OK.
Not long after that, Microsoft started talking about Windows 8, UWP, and Windows on ARM, and that's kind of where I lost track. With Windows 8, there were going to be a variety of ways that you could build desktop GUIs. Some of them seemed to be inherited from XAML. But now, instead of C++/CLR, you would use some kind of COM 2.0 thing. So you didn't need to build a hybrid .NET app, but the API wasn't great. In addition, Microsoft supported some kind of HTML-based app - which was some kind of thing inspired by Electron... but running on the IE engine instead of Chromium.
And now... this.
I don't know what most people ship these days, when they build Windows UIs. It's a mix of Electron (eg Slack, VS Code), as well as QT, and good ol' Win32, that we've had since the 90s.
So this is why people are tired. Microsoft keeps shipping yet another UI framework - and the people have stopped believing that they can invest in this thing, which is inevitably going to be replaced by yet another thing in 3 years time.
If you stick to plain ol' Win32, you can be pretty sure your app will be trivial to compile and run for decades, so that's what I do for little Win32 UIs.
But suddenly targeting Windows is much less interesting, but they still have the monopolist's arrogance: "You will rewrite your app to work on our new UI framework, right? Right...?" What actually happens is that every deprecation and every new thing weakens their ecosystem. Their biggest draw is in legacy software, and they variously want to throw out their legacy support, or create tomorrow's legacy today with new frameworks that end up abandoned.
And a large majority of factory and laboratory automation control systems.
So my plan was to use React + Electron since it's easy and quick, but it feels like overkill.
So I considered downloading VS Community and using C# and .NET for it, but that also kinds of feels like overkill.
So I considered using Win32 APIs, but I remember the sample hello world program's source being surprisingly complex.
So I considered learning MFC and using that since I heard it's a decent layer on top of Win32, but then I'd have to relearn C++.
So I opened the WinUI page and the WinJS repo linked to somewhere else in here, and both seem like dead ends.
This is why I still have LibreOffice installed. Which of course also feels like overkill.
Or moving logic, as it were... I'm sure I wasn't the only one who has made the "button you can't click"[1] prank application after finding out that UI controls are windows, and can be resized and moved too.
[1] A single window containing a button labeled "CLICK ME", which jumps to a random place every time your mouse approaches it. I have also made a version without the window, or rather the containing window, which has the slightly amusing appearance of a lone button that jumps around the desktop. Labeling it "click me to close" of course makes it even more fun...
"I don't know what most people ship these days, when they build Windows UIs. It's a mix of Electron (eg Slack, VS Code), as well as QT, and good ol' Win32, that we've had since the 90s. "
Most probably use WPF but that's not much fun.
Do you still make apps for Windows?
Life science research laboratories and many medical devices are pretty much some form of Windows running a mix of MFC, Forms or WPF, dependending on when the application was made.
The large majority of device manufactures, delivers their SDKs as a mix of DLLs and COM libraries, with samples written in C++, VB and C#.
While HN might talk all day about R vs Python vs Julia, many of the researchers actually use Excel or Tableau, and when their built-in programming cannot keep up, it gets reborn as a .NET desktop app.
https://old.reddit.com/r/csharp/comments/f9i9hc/which_one_is...
Just like Java
From github...
The Windows UI Library (WinUI) provides official native Microsoft UI controls and features for Windows UWP apps.
WinUI is the easiest way to build great Fluent Design experiences for Windows.
WinUI can be used in any Windows 10 UWP XAML app, or in a Xamarin.Forms app running on Windows 10 using native view embedding.
2. Wait for .NET 5.
3. Try adopting WinUI 3+ controls as XAML Islands, one at a time until your XAML is more WinUI than WPF.
4. Eventually drop remaining WPF dependencies and declare it a UWP app.
5. Profit?
The thing that was missing before was a nice UI framework to go along with it; hopefully this WinUI thing addresses that.
In my personal opnion, it might be a good thing that apps that can read each others' memory, etc. can exist, but they shouldn't be the default, users should have to explicitly opt in to allowing that, and not in a way that will become just another dialog box for most people to mindlessly click OK on.
1: extremely intense or severe; "blistering heat"
2: very rapid; "a blistering pace"
P.S. Actual download link: https://aka.ms/winui/alpha/projecttemplates
Basically it is the UWP version of Android's Jetpack.
Win32 is done, frozen in Windows XP view of the world, the future keeps being UWP.
UI consistency isn't Windows strongest point. I'm glad they're trying to fix it.
WPF, UWP, SilverLight, Metro. Am I forgetting any?
For UIs that can be achievable by web browser, we use web browser. For video games, we use dedicated libraries. For native utility programs, we use cross platform libraries or maybe native libraries.
They added yet another half-baked library that only works on MS products and the only developer who has a misfortune to use WinUI will be the one who has to support very narrow platform(one specific model of MS hardware) with the demand of very narrow customer(just one company asking a utility tool and specify the exact UI library it use).
Everyone should read the xkcd 927 before inventing their own yet another library. https://xkcd.com/927/
Outside of Microsoft (including Office), who actually develops native windows apps which would use this any more?
- Things like games or steam don't use native+OS-specific UI. - Internal company software (including finance, etc) seems to always be web-based. - Tools like slack, etc all seem to be Electron.
Any "off-the-shelf app" will probably want something that's cross platform -- I don't think anyone targets "windows only" any more, right?
The exception is and always was media creation, where Mac always had a foothold.
But for every normal boring enterprise out there, so long as every customer is a business where everyone runs windows, that’s your target.
At this point HTML+JS is one option that gives a good amount of flexibility and support, and it looks like OSes should just be a browser. In my view, any OS should be able to use any windowing manager at the same time, provided they can use the same rendering core.
I like building simple interfaces using SDL or SFML, and as long as you only redraw when needed, it's just good enough. The godot editor works that way, that's how it's able to work on all platform: you have a small throbber that turns indicating when it's redrawing.