Template child controls events with multiple templates

Dec 8, 2009 at 10:10 AM

Hi, thanks for the great library.

I am trying to use it in a project where listboxes need to host different templates.

I've achieved that by listening to the BindTemplate event, and changing the template in the TemplateEventArgs that I receive.

But when I do this, the buttons inside my template doesn't fire any click event. I've been debugging Fluid but I cannot find where is the problem.

If I use a list with the same template (and only this template), buttons fire events correctly.

Anyone had this problem before? Solutions? 

Thanks in advance.

 

Dec 8, 2009 at 10:31 AM

Best way of fixing a bug is saying "I cannot fix this". Just posted this, just fixed it.

My problem was that I was creating new template instances every time, but BindTemplate is fired every time the template for a item is requested (drawing, event handling, etc), so the events were being propagated to a control that had no listeners yet.

The solution was as easy as reusing the previous constructed template instance.

Thanks for your time. Hope this helps anyone else.

May 2, 2012 at 3:29 PM

With a small chance you might read this, did you try to alter item heights?

I found that fluid uses listbox.itemHeight for maybe too many things and template heights don't have anything to do with drawing. The logic just replaces everything but template width.