Let's say I have a large XAML page. On this page are dozens of text boxes, buttons, etc, and these controls need to be shown/hidden/modified based on various conditions (permissions, view-model states, whatever). Two possible approaches to set up the visual transitions are:
My question: purely from the perspective of performance (speed and memory footprint), is one or the other approach clearly better? Is the second approach, loading up the page with bindings, liable to weigh it down? Or is the difference likely to be negligible?
I don't have a test or benchmark to prove it, but reasoning as follows suggests that the visual-states approach should be faster by far.
For the binding scenario:
PropertyChanged
is raised.The visual state scenario has none of these handlers to churn through:
It seems clearly better for performance to use Visual State Manager, than to set up an excess of view-to-viewmodel bindings.
Edit John Gossman also noted (a long time ago) that bindings can be heavy, and can start consuming excess memory in large applications. In the linked article, he claims to have saved 100MB by replacing all bindings with a single static callback.