Xamarin.forms: [Bug] OnIdiom not working with the new RowDefinitions ColumnDefinitions syntax

Created on 25 Nov 2020  路  1Comment  路  Source: xamarin/Xamarin.Forms

Description

xaml is not accepting OnIdiom when used with the new syntax of RowDefinitions and ColumnDefinitions https://github.com/microsoft/microsoft-ui-xaml/issues/673:

RowDefinitions="{OnIdiom Tablet="*,*,auto", Phone="*,*,*"}" highlight:

expected '>' AND expected '}'

Tried the following workaround but crashing the app on Xamarin and throwing the exception:

System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'

 <Grid.RowDefinitions>
            <RowDefinitionCollection>
                <OnIdiom x:TypeArguments="RowDefinitionCollection">
                    <OnIdiom.Phone>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </OnIdiom.Phone>
                    <OnIdiom.Tablet>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="auto"/>
                    </OnIdiom.Tablet>
                </OnIdiom>
            </RowDefinitionCollection>
        </Grid.RowDefinitions>

Expected Behavior

To be accepted as a valid syntax.

Actual Behavior

Invalid syntax.

Basic Information

  • Version with issue: 5.0.0.1790-pre4

Environment

Visual studio 2019 16.8.1

Xaml </> grid 5 bug

Most helpful comment

Your XAML syntax is invalid because of your nested double quotes, it should be

RowDefinitions="{OnIdiom Tablet='*,*,auto', Phone='*,*,*'}"

That said, it's not working; at runtime, it does give an error:

SetValue: Can not convert *,*,* to type 'Xamarin.Forms.RowDefinitionCollection

_12965 Repro.zip

>All comments

Your XAML syntax is invalid because of your nested double quotes, it should be

RowDefinitions="{OnIdiom Tablet='*,*,auto', Phone='*,*,*'}"

That said, it's not working; at runtime, it does give an error:

SetValue: Can not convert *,*,* to type 'Xamarin.Forms.RowDefinitionCollection

_12965 Repro.zip

Was this page helpful?
0 / 5 - 0 ratings