I have created my own ExtendedTabControl to totally change it’s apperance. It works ok. I have also created CloseableTabItem control. It works as well. However… so far I have manually put CloseableTabItem in my ExtendedTabControl this way:
<etc:ExtendedTabControl>
<etc:CloseableTabItem Header="First Item">
<...some content... />
</etc:CloseableTabItem>
</etc:ExtendedTabControl>
Now I want to bind ObservableCollection to my ExtendedTabControl. Objects inside the Collection contains: header and contentText. I set ItemSource, ok, works. But how can I make the TabItems be my CloseableTabItems? What is more, how to bind my class objects to that CloseableTabItems? I Have noticed TabControl has a property called ItemTemplate, but setting it does not change it’s apperance totally. There is still a background which I can’t change. So an apperance works, but binding does not or the bindings work, but the apperance only partly. What can I do? Please help.
In your
ExtendedTabControlcode you need to change the item container which is generated for items to yourClosableTabItem:(There is a related method,
IsItemItsOwnContainerOverride, which you might also want to override)TabControlshave two template you can set, theContentTemplatewhich templates the item content area, and theItemTemplatewhich should template the header.To modify other properties on the generated tabs use the
ItemContainerStyle, which now has aTargetTypeofClosableTabItem.