Quantcast ESOUI - View Single Post - ApplyTemplateToControl question
View Single Post
03/15/19, 08:03 PM   #18
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 679
As for the comment "STRANGE: <OnInitialized> is not called for this control, ..."

ApplyTemplateToControl does not create the target control -- it must've been created previously (and its OnInitialized handler called, if it had any) -- I think that's why it doesn't call the template's top-level <OnInitialized> handler (it would be called if you used the template to CreateControlFromVirtual). The template's children that didn't exist on the target control actually do get created by ApplyTemplateToControl, so their <OnInitialized> get called.

Anyway, I think you're trying to use ApplyTemplateToControl for something it's not been intended for. There's no way to remove a control from the UI once it's been created. It can be repurposed or hidden, but it's there until /reloadui.

I suggest you create a distinct control container for each mode and switch between them by showing one and hiding the other.
  Reply With Quote