Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial foreground of Icon in TabItem Header #3670

Open
corvinsz opened this issue Sep 12, 2024 · 2 comments
Open

Initial foreground of Icon in TabItem Header #3670

corvinsz opened this issue Sep 12, 2024 · 2 comments
Labels
bug evaluation required Items is pending review or evaluation by the team

Comments

@corvinsz
Copy link
Contributor

Bug explanation

When using a PackIcon inside of the header of a TabItem, 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):
TabItemForegroundBug

Here is a repo that showcases this bug.

Version

5.1.0

@corvinsz corvinsz added bug evaluation required Items is pending review or evaluation by the team labels Sep 12, 2024
@corvinsz
Copy link
Contributor Author

I noticed when setting the Style of the TabControl explicitly, the icon has the correct foreground:
image

<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>

@danaildinev
Copy link

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug evaluation required Items is pending review or evaluation by the team
Projects
None yet
Development

No branches or pull requests

2 participants