3 ms·
Once you understand what the equivalent would be in a pure Win32 application, XAML starts to make much less sense... making a window resizeable involves setting
by userbinator 11y ago
Once you understand what the equivalent would be in a pure Win32 application, XAML starts to make much less sense... making a window resizeable involves setting one bit in the window styles and responsive just means a loop over the contents to move them to the right places when WM_SIZE message is received.
Declarative UIs in XML are more verbose and less flexible than just putting the appropriate expressions in a simple resize-recalc table, which is what the Win32 equivalent would be.
- vesinisa 11y agoWell, essentially your re-layout loop would probably end up applying some specific pattern in code. Declarative UI is basically a way of doing that in a way that other developers have a better chance of understanding, and is less prone to bugs. Not that you couldn't go the hard way and write the responsive UI with code only. A XAML file is essentially just a recipe for creating the hierarchy of objects in your UI, that the framework then goes on to draw. Everything that is done in XAML can just as well be done with code.
- exDM69 11y agoWithout addressing the XAML mess, Window resizing in WINAPI is a complete mess too. You toggle whether a window is resizable by setting the window style (wtf!) with WS_THICKFRAME. When resizing windows, you need to handle three different messages (WM_ENTERSIZEMOVE, WM_EXITSIZEMOVE, WM_SIZE). To set minimum/maximum size, you respond to a WM_GETMINMAXINFO message. All I wanted was SetWindowMinMaxSize(hwnd, min_size, max_size) and an event to tell me the window has resized. That's it. This complexity allows apps to misbehave in various ways, either unintentionally, on purpose or maliciously. Windows programming is so darn complicated that it doesn't make any sense.
- imtringued 11y ago>responsive just means a loop over the contents to move them to the right places when WM_SIZE message is received. So you're suggesting I should handroll my own layout manager? That sounds several orders of magnitude more complicated.