开发者

ITemplate, the reason for leaving InstantiateIn(Control container)

I'm implementing the ITemplate interface in ListView control. If i realize it for ItemTemplate in my custom class, everything will be OK. I mean, the runtime will invoke InstantiateIn when i use

ListView.ItemTemplate = new CustomClass(); 

CustomClass :ITemplate 
{
    public void InstantiateIn(Control container)
    {
        HtmlTable table = CreateHeader();
   开发者_高级运维     container.Controls.Add(table);
    }
    ...
}

But i want to do the same with ListView.LayoutTemplate. In this case, the runtime invokes InstantiateIn only one time, but every next update it leaves my method. What is the reason for it?


Layout template says how the root container does look like, it is not per item thing.


I have to change my LayoutTemplate after clicking different buttons.

And My LayoutTemplate has a header for the whole ListView. I have to change it, it depends on button.

Also i have two custom classes with implementations of ITemplate (one for ItemTemplate and one for LayoutTemplate). I am going to realise the folowing behaviour:

1). If i click Button1

ListView.ItemTemplate = new CustomItemClass1();
ListView.LayoutTemplate = new CustomLayuotClass1();

2). If i click Button2

ListView.ItemTemplate = new CustomItemClass2();
ListView.LayoutTemplate = new CustomLayuotClass2();

But i can't see my header of LayoutTemplate more, then one time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜