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

OnPlatform control of type x:Double is not accessible as font size #22461

Open
Phil9753 opened this issue May 16, 2024 · 2 comments
Open

OnPlatform control of type x:Double is not accessible as font size #22461

Phil9753 opened this issue May 16, 2024 · 2 comments
Labels
area-xaml XAML, CSS, Triggers, Behaviors platform/android 🤖 platform/iOS 🍎 platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@Phil9753
Copy link

Phil9753 commented May 16, 2024

Description

I defined an OnPlatform class of type x:Double in my main Styles.xaml which I want to use for defining different font sizes per platform. The problem is when I want to call the resource via the specified x:Key the font size of the label does not change.

Steps to Reproduce

My Styles.xaml file:

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:controls="clr-namespace:ClientApp.Source.Controls"
    xmlns:views="clr-namespace:ClientApp.Source.Views">

    <OnPlatform x:Key="TinyFontSize" x:TypeArguments="x:Double">
        <On Platform="Default" Value="12" />
    </OnPlatform>

In a ContentPage I created following label:

<Label FontSize="{StaticResource TinyFontSize}" Text="Test" WidthRequest="200"/>

but the font size of the label does not change to size 12, only when I replace {StaticResource TinyFontSize} with a numeric value.

When I create following resource in the Styles.xaml file:

<x:Double x:Key="SmallFontSize">13</x:Double>

it would work fine but then I can not change the value depending on the operating system from the main Styles.xaml.

I found an example on Github in the eShop repository: https://github.com/dotnet/eShop/blob/main/src/ClientApp/Views/CheckoutView.xaml.

But even when I checkout this project and run the ClientApp it does not work...

Link to public reproduction project repository

https://github.com/dotnet/eShop/blob/main/src/ClientApp/Views/CheckoutView.xaml.

Version with bug

8.0.21 SR4.1

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, Windows

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

@Phil9753 Phil9753 added the t/bug Something isn't working label May 16, 2024
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@jaosnz-rep
Copy link
Collaborator

Can repro this issue at Android/Windows platforms on the latest 17.10 preview 7 (8.0.40, 8.0.21, 8.0.3).
https://github.com/dotnet/eShop/tree/main/src/ClientApp

@jaosnz-rep jaosnz-rep added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels May 17, 2024
@mattleibow mattleibow added the area-xaml XAML, CSS, Triggers, Behaviors label May 17, 2024
@PureWeen PureWeen added this to the Backlog milestone May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-xaml XAML, CSS, Triggers, Behaviors platform/android 🤖 platform/iOS 🍎 platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants