Hi,for about 2 hours I try to find out how to "just style the heads" of XamTabControl. (I could extend the first sentence with many frustration words, but this isn't constructive.) I want to set a brush to the background, foreground (text) and border. For active and inactive tab headers. A screenshot (from an Infragistics Forms application) shows an example layout.
I looked to the example "Customizing the XamTabControl", to the article "About Styling xamTabControl", to forum topics, to the local documentation and to Google. Additionally I made experiments with my application. For example I added the following code to my control ressources, but nothing happens:<SolidColorBrush x:Key="{x:Static igWindows:PrimitivesBrushKeys.TabContentBackgroundFillKey}" Color="Pink" />
So how I can apply such simple styles to the tab headers?
Where can I find an overview of the available keys for XamTabControl in the local documentation?By the way: It would be useful when your forum post editor has a feature for "code style" and an image upload service.Thanks in advance,Andreas
Hello Andreas,
Thank you for your post!
To find an overview of the available keys for the XamTabControl with respect to the tab headers, I would recommend that you look into the default style for TabItemEx, which is located in the XAML file commonly found at this directory: C:\Program Files (x86)\Infragistics\2015.1\WPF\DefaultStyles\Windows\PrimitivesGeneric.xaml. For styling the background, foreground, and border properties of these tab headers though, I wouldn't really recommend overwriting this keys, since they may be used elsewhere in the application. Instead, I would recommend simply writing a style for TabItemEx and setting the Background, Foreground, and BorderBrush properties.
The above will work for the inactive tabs in the XamTabControl, but for styling the active tabs, you may want to consider modifying the template of the TabItemEx, as these colors are determined by elements internal to the element's template. I have attached a sample project that demonstrates a way you can modify the template for active and inactive tabs with the XamTabControl.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Hallo Andrew,thanks for your quick and useful reply.I modified your sweet example project and now the TabControl looks like I want. Here a screenshot. (Tab 3 is active and Tab 4 is in mouseOver state.)One big mistake of yesterday was, that I used the common TabItem instead of igWindows:TabItemEx. Because of this I didn't see changes while playing with styling code.Unfortunately I still have a problem:In the trigger for the active tab I added bold FontWeight.The problem: By this setting the whole control content becomes bold. (In contradistinction to the font style the colour settings only apply to the tab heads - as I want.)As I read for this I need to define a HeaderTemplate with triggers, but I couldn't create a working solution.After another 2 or 3 hour of searching, reading and code playing I gave up.Do you know the trick?
I have modified the sample project that I originally sent you to include a HeaderTemplate in the TabItemEx style that was there before. The HeaderTemplate is just a simple TextBlock with its Text property bound to the data context of that TextBlock, which will be the string used for the Header property of the TabItemEx. After giving this TextBlock a name, I moved the triggers that were in the initial re-template of the TabItemEx into the header template and the Setters of these triggers are targeting the TextBlock by name. The triggers are also now DataTriggers with RelativeSource AncestorType bindings to the TabItemEx's properties.
I have attached the modified sample to demonstrate the above.
Hi Andrew,thank you very much for your extended example and the detailed explanation !! (-:Greetings from GermanyAndreas