开发者

WPF TabControl add extra tabs to a bound control

I have a Tab Control with a ItemsSource Binding. ...

I want to add a predefined tab to the front called 开发者_如何学GoAll that has an aggregate of all the other tabs, and I would also like to add a button at the end called Add so I can add a new tab. Is there an easy way of doing this ?

Thanks, Raul


The easiest way is to go with MVVM (the example in the url acutally contains TabControl bound to a ViewModel). Your ViewModel that you bind your TabPages against could expose an observablecollection of items where the first item is always a ViewModel instance that holds you aggregate data. All follwing items are the ViewModel instances for the rest of the tabpages. Your ViewModel would also expose a ICommand AddTabPage wich adds a new item to the obeservablecollection. The TabPage will pick up this change automatically. You'd have a button whose Command property is bound to this command.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜