View Single Post
03/16/19, 12:45 AM   #19
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
Originally Posted by merlight View Post
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.
Thanks for the clarification, merlight! I decided to wirte LibTemplate for that purpose. Concerning the initialization: I put a zo_callLater(d("I am a template"),2000) into the applied TLW's onInitialized - never shows. So templates that are applied to other controls seem to never fire their onInitialized.
  Reply With Quote