views:

166

answers:

1

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

I want to add a predefined tab to the front called All 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

A: 

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.

bitbonk
I was kinda hoping you wouldn't say that... The collection is used else ware in the View's. I guess I can create another collection with the Aggregate and have it monitor the initial collection for any changes.
HaxElit
its funny how long i have spent struggling not to do the hours work and build the view model. every time i do, i get ease of use, flexibility and control. yet i always think im going to have to do more work.
Aran Mulholland
LoL good point!I'll just bite the bullet.Thanks
HaxElit
Isn't there any better way? I am using EF and bind the data right against the EF collection using a CollectionViewSource StaticResource.
Shimmy