Open corvinsz opened 1 week ago
I noticed when setting the Style of the TabControl
explicitly, the icon has the correct foreground:
<StackPanel VerticalAlignment="Center">
<TabControl HorizontalAlignment="Center">
<TabItem>
<TabItem.Header>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Bin" />
<TextBlock Text="Tab 1" />
</StackPanel>
</TabItem.Header>
<TextBlock Text="Content 1" />
</TabItem>
</TabControl>
<TabControl Margin="0,30,0,0"
HorizontalAlignment="Center"
Style="{StaticResource MaterialDesignTabControl}">
<TabItem>
<TabItem.Header>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Bin" />
<TextBlock Text="Tab 2" />
</StackPanel>
</TabItem.Header>
<TextBlock Text="Content 2" />
</TabItem>
</TabControl>
</StackPanel>
Another fix (hack) I found several months ago was setting the foreground of the icon from the textblock foreground in the tabitem header textblock.
<TabItem.Header>
<StackPanel Orientation="Horizontal">
<md:PackIcon Kind="Album"
Foreground="{Binding Foreground, ElementName=tabTbAlbums}"/>
<TextBlock x:Name="tabTbAlbums"
Text="{DynamicResource stringAlbums}"/>
</StackPanel>
</TabItem.Header>
Bug explanation
When using a
PackIcon
inside of the header of aTabItem
, the PackIcons foreground is initially not set correctly. Once you switch the tabs the foreground fixes itself (notice how the color of the Icon in the first tab changes from white to green):Here is a repo that showcases this bug.
Version
5.1.0