ESOUI - View Single Post - ApplyTemplateToControl question
View Single Post
03/14/19, 07:46 PM   #7
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 679
Originally Posted by Letho View Post
I know, i thought ApplyTemplateToControl() might work as some sort of "ControlPoolManagementFactory", quite the way I currently handle it, but more sophisticated and elegant. Could you explain a (or probably THE) typical use case for ApplyTemplateToControl() then? I don't see a sense in it if it isnt about replacing controls.
It may be useful for lazy construction. You can create the parent (empty or only basic) control at startup, and then before it needs to be shown, choose which template to use for its contents (e.g. based on user settings, or player character class, or whatever, ...) and then apply the template. It's like two-step CreateControlFromVirtual -- in most cases you could just create the control in one step with CreateControlFromVirtual, but one limitation of such control (i.e. not created from XML) is that it cannot handle "OnUpdate" events.
  Reply With Quote