Is rebuilding the entire visual tree per interaction (immediate-mode style) encouraged in WinUI 3?

Harshithraj1871 1,706 Reputation points
2025-07-07T09:04:46.7233333+00:00

Hi,

I'm working on WinUI3 desktop application in C++ without XAML. I've been experimenting with building UIs in a more "immediate-mode" style using WinUI 3, basically clearing and rebuilding the entire visual tree every time the user interacts with something, like clicking a button or typing in a field.

This feels pretty intuitive for small UIs or prototyping, but I'm wondering if it's something that could cause issues in the long run.

Is WinUI 3 designed around a retained-mode model where the system expects the UI tree to stay relatively stable?Could this kind of frequent UI rebuilding lead to performance problems, like extra layout passes or rendering overhead?

I want to understand whether this is safe to do in more dynamic apps, or if it's better to stick to the traditional retained-mode approach and just update properties/state instead of tearing things down.

Windows development | Windows App SDK
0 comments No comments
{count} votes

Accepted answer
  1. Darran Rowe 2,171 Reputation points
    2025-07-07T13:17:48.41+00:00

    WinUI 3 is designed around an API similar to Windows.UI.Composition. This is documented.

    Windows.UI.Composition is itself similar to DirectComposition, where it is a direct communication channel to DWM. They are all very much retained mode APIs.

    But if anything, I would think that rebuilding the Visual Tree is most likely going to hurt performance, and maybe affect event handlers and possibly manipulation.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.