I am creating tabItemEx dynamically in code behind( c#). for that tabItemEx how to add image to the header part?
Hello,
One way would be to retemplate the TabItemEx element and create a ControlTemplate with an image inside it. You can bind the Source property of that image to the Tag of the TabItemEx. When creating the TabItemEx, you can set its Tag property to a BitmapImage object which will be your image source.
You can see an example for this in the XamFeatureBrowser under XamTabControl - Themes and Style - Customizing the XamTabControl.
Hope this helps.
I checked the example you mentioned. there it is done in xaml only not in code behind file.
Please can you send me the sample code?
Ritesh,
Creating a template in code behind can be achieved with the FrameworkElementFactory class, but it is deprecated by Microsoft. You can still create the DataTemplate in xaml and get it as a Resource from the Resources. Binding the Image's source property to the Tag will give you the possibility to change the image's source, by changing the Tag of the TabItemEx.
So it comes down to what you want to do in procedural code -
Do you want to create the template or do you want to change/add the image?