c# - WPF "Expand All" Control Load Time -
i have integrated feature in tool allows me expand recursively. realise slow process anyway currently. have maybe 100 nested controls expanded @ once, calling expand means each control/datatemplate etc processed @ once.
this causes tool lock 10 seconds before responding. of course, once view hierarchy has been constructed, fast (i can collapse , expand instantly on). seems little odd there isn't faster way generate large forms, wouldn't consider 100-500~ controls many.
i have looked virtualisation, doesn't appear useful me in case because controls expanded @ once. fine if expand them on singular basis.
edit:
updates we're needed question describe layout of window is:
i have number of textboxes, comboboxes, sliders nested inside of number of expanders. each expander can contain n number of expanders, recursive extent. depending on how data laid out. of these data types (which represented datatemplates) may contain stackpanels if needed , numerous grids layouts.
to expand means iterate each expander (which isexpanded bound isexpanded property). set property on each data type (and children) true. , let binding work of expanding everything. causes every single control added @ once.
thanks
so after reading edited question, have guess what's going on:
the ui busy on rendering controls. , assume there's not data kept behind in viewmodels bound, data not point in issue.
when expander control gets isexpanded = true
first time, xaml parsed (object / resource parsing, not compiling) , visual tree children created. 100-500 visual tree elements high number rendering, because each of them (if it's belonging system.windows.controls
namespace) consists of many sub-controls (border
, grids
, textbox
,..).
what can achieve not shortening expanding time, unblock ui: advise dispatcher handle isexpanded
asynchronously , see how behaves. requires don't use expanders default action: in arrow button click handler, skip default handling , insert (isexpanded
bound viewmodel property here):
dispatcher.begininvoke(dispatcherpriority.normal, new action( () => { this.isexpanded = true; } ));
Comments
Post a Comment