How to bind data to TabControl's each TabItem

Oct 9, 2009 at 8:42 AM

Hi, guys,

I have an interesting problem about TabControl.

I don't know how many TabItem should be loaded in to the TabControl, all the data come from a List<string>. So I will binding each string to the TabItem's Header property.

Now I use foreach syntax to load data to the TabControl, but I need a binding for that.

Anyone has some idea about it?

 

Jianqiang

 

Oct 13, 2009 at 10:42 PM

Hi Jianqiang,

I assume you are using Silverilght based on your previous questions.

Are the TabItems views in a TabControl region? If they are, you can assign the value to a property in the View’s ViewModel (for example HeaderInfo) and bind to it using XAML like explained here. Take into account that there is an issue with the HeaderInfo in Silverlight 3.

If you are manually creating the TabItems you can perform the bindings in code using the Binding class. If this is the case you might get more information in the Silverlight forums.

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman