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

OnIdiom not working when using as style resource #10894

Open
nschoenberg opened this issue Oct 25, 2022 · 5 comments
Open

OnIdiom not working when using as style resource #10894

nschoenberg opened this issue Oct 25, 2022 · 5 comments
Labels
area-xaml XAML, CSS, Triggers, Behaviors migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst 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

@nschoenberg
Copy link

nschoenberg commented Oct 25, 2022

Description

Currently migrating from XF to Maui, I have multiple pages/views where I defined OnIdiom as resource like so:

<Grid.Resources>
        <OnIdiom x:Key="LayoutGridColumnWidth" x:TypeArguments="GridLength" Default="0.25*" Phone="0.33*" />
</Grid.Resources>

Im using those resources multiple times, like this:

<Grid.ColumnDefinitions>
        <ColumnDefinition Width="{StaticResource LayoutGridColumnWidth}" />
</Grid.ColumnDefinitions>

I get the following error:
XFC0009 No property, BindableProperty, or event found for "Default", or mismatching type between value and property. Futura.IA.Models.Views D:\...\AddressView.xaml

The same code is working fine for my Xamarin.Forms Project. I can workaround the issue by not using the StaticResource extension and replace the Style with OnIdiom Markup like this:
<ColumnDefinition Width="{OnIdiom Default=0.25*, Phone=0.33*}" />

Is this working as intended? If yes I have to change a lot of views

Steps to Reproduce

Add a new Page or Control and use OnIdiom as Style Resource as mentioned above or compile the sample repo.

Link to public reproduction project repository

https://github.com/nschoenberg/OnIdiomRepro

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, Windows, macOS

Affected platform versions

Windows 11

Did you find any workaround?

Yes, using OnIdiom as markup extension directly instead of static resource

Relevant log output

No response

@nschoenberg nschoenberg added the t/bug Something isn't working label Oct 25, 2022
@PureWeen PureWeen added the area-xaml XAML, CSS, Triggers, Behaviors label Oct 25, 2022
@PureWeen
Copy link
Member

@StephaneDelcroix thoughts? Should we add this to OnIdiom ?

@PureWeen PureWeen added proposal/open area/migration 🚚 t/bug Something isn't working and removed t/bug Something isn't working proposal/open labels Oct 25, 2022
@nschoenberg
Copy link
Author

One additional note: It is working fine when OnIdiom is used as resource when using x:Int32 as type, like so:
<OnIdiom x:Key="ZipCodeRow" x:TypeArguments="x:Int32" Default="1" Phone="2" />

@jsuarezruiz jsuarezruiz added this to the Backlog milestone Oct 26, 2022
@ghost
Copy link

ghost commented Oct 26, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@homeyf homeyf added s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage labels May 30, 2023
@homeyf
Copy link
Collaborator

homeyf commented May 30, 2023

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 1.0. Can repro on android platform with above project.
https://github.com/nschoenberg/OnIdiomRepro
image

@RodgerLeblanc
Copy link
Contributor

RodgerLeblanc commented Jun 20, 2023

The GridLength struct seems to be missing the TypeConverterAttribute :

namespace Microsoft.Maui
{
    /// <include file="../../docs/Microsoft.Maui/GridLength.xml" path="Type[@FullName='Microsoft.Maui.GridLength']/Docs/*" />
    [DebuggerDisplay("{Value}.{GridUnitType}")]
    [System.ComponentModel.TypeConverter(typeof(GridLengthTypeConverter))]  // <--- This line is missing
    public readonly struct GridLength
    {
        //...
    }
}

GridLengthTypeConverter might have to be moved to \src\Core\src\Converters\ folder in order to be referenced by GridLength, not sure of the impact of such change.

In the meantime, declaring the <OnIdiom> values explicitly using their actual type instead of using type conversion will bypass the issue :

<Grid.Resources>
    <OnIdiom x:Key="LayoutGridColumnWidth" x:TypeArguments="GridLength">
        <OnIdiom.Default>
            <GridLength>0.25*</GridLength>
        </OnIdiom.Default>
        <OnIdiom.Phone>
            <GridLength>0.33*</GridLength>
        </OnIdiom.Phone>
    </OnIdiom>
</Grid.Resources>

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 migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst 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

6 participants