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

IconSources don't respect Style values #2568

Closed
michael-hawker opened this issue May 29, 2020 · 3 comments
Closed

IconSources don't respect Style values #2568

michael-hawker opened this issue May 29, 2020 · 3 comments

Comments

@michael-hawker
Copy link
Collaborator

I just realized that I can't style an Icon/IconSource, when I get the FontIconSource from the developer's XAML it's fixed at 20 for FontSize, any amount of style I have in my template is ignored and won't inherit or override that FontSize value, even if I call ClearValue on the FontIcon, as that just sets it back to 20...

For instance if I have the following XAML:

<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>
        <FontIconSource FontFamily="Segoe MDL2 Assets" Glyph="&#xE115;" x:Key="MyFontIconSource"/>
        <x:Double x:Key="MyTextSize">64</x:Double>
    </Page.Resources>

    <Grid Padding="40">
        <ContentPresenter FontSize="{StaticResource MyTextSize}">
            <StackPanel>
                <IconSourceElement IconSource="{StaticResource MyFontIconSource}"/>
                <TextBlock>Text</TextBlock>
            </StackPanel>
        </ContentPresenter>
    </Grid>
</Page>

The TextBlock value respects the parent FontSize value (set or from style), but the IconSourceElement does not, event though I didn't specify a FontSize property in the resource (if I did, I'd expect it to use that like other style/override scenarios).

Originally posted by @michael-hawker in #1494 (comment)

@michael-hawker
Copy link
Collaborator Author

It's odd too that these two scenarios produce different results because of this:

image

      <AutoSuggestBox QueryIcon="Setting" Margin="0,0,0,16"/>
      <AutoSuggestBox>
        <AutoSuggestBox.QueryIcon>
          <IconSourceElement>
            <SymbolIconSource Symbol="Setting"/>
          </IconSourceElement>
        </AutoSuggestBox.QueryIcon>
      </AutoSuggestBox>

So even those these both end up as SymbolIcon the one coming from an IconSource doesn't respect the FontSize of the ContentPrenter.

image

@StephenLPeters StephenLPeters added team-Controls Issue for the Controls team area-Styling and removed needs-triage Issue needs to be triaged by the area owners labels Jun 2, 2020
michael-hawker added a commit to CommunityToolkit/WindowsCommunityToolkit that referenced this issue Jun 3, 2020
Ref microsoft/microsoft-ui-xaml#2568
Also added WPF TryFindResource method to LogicalTree helpers - thanks for review/assist @rudyhuyn
@marcelwgn
Copy link
Contributor

@StephenLPeters @michael-hawker There also is the MUXC FontIconSource, which seems to respect the property properly as it passes all properties down to the generated FontIcon. This issue however is about the WUXC FontIconSource. Does it make sense to keep this issue open as with WinUI 3, those would be unified, and then we would use the MUXC FIS which works correctly?

@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants