Type OnPlatForm not found

voidstreamvoidstream FRMember ✭✭✭
edited October 19 in Xamarin.Forms

Hello,

I have this exception on my App.xaml: _Xamarin.Forms.Xaml.XamlParseException: Position 62:5. Type OnPlatForm not found in xmlns http://xamarin.com/schemas/2014/forms

My XAML with exception is:

            <!-- ______________________________________________________________________ -->
            <!-- Cross Platform adjustment -->
            <OnPlatForm x:Key="PickerAndEntryHeight"
                        x:TypeArguments="x:Double"
                        iOS="30"/>
            <!-- ______________________________________________________________________ -->
            <!-- Controls Hack -->
            <Style TargetType="Entry">
                <Setter Property="HeightRequest" Value="{DynamicResource PickerAndEntryHeight}"/>
            </Style>
            <Style TargetType="Picker">
                <Setter Property="HeightRequest" Value="{DynamicResource PickerAndEntryHeight}"/>
            </Style>
            <Style TargetType="DatePicker">
                <Setter Property="HeightRequest" Value="{DynamicResource PickerAndEntryHeight}"/>
            </Style>

Why i have an exception whereas this XAML works :smile:

            <!-- ______________________________________________________________________ -->
            <!-- Cross Platform adjustment -->
            <OnPlatform x:Key="FormLabelStyleMargin" 
                        x:TypeArguments="Thickness"
                        WinPhone="0,10,0,-10"
                        Android="0,10,0,-10"
                        iOS="0,10,0,2"/>

            <!-- ______________________________________________________________________ -->
            <!-- Controls Style -->
            <Style TargetType="Label" x:Key="FormLabelStyle">
                <Setter Property="FontSize" Value="12"/>
                <Setter Property="TextColor" Value="{DynamicResource FormLabelTextColor}"/>
                <Setter Property="Margin" Value="{DynamicResource FormLabelStyleMargin}"/>
            </Style>

Anyone has idea? @NMackay ? @ClintStLaurent ?

Best regards

Tagged:

Best Answer

Answers

  • DarshanJSDarshanJS USMember ✭✭✭
    edited October 19

    @voidstream said:

    try below code by doing changes required based on your requirements for entry

                <Style  x:Key="MyTitleLabel" TargetType="Label" BaseResourceKey="TitleStyle">
                    <Setter Property="Font" >
                        <Setter.Value>
    
                            <OnIdiom x:TypeArguments="Font">
                                <OnIdiom.Phone>
                                    <OnPlatform x:TypeArguments="Font" iOS="14" Android="16"  />
                                </OnIdiom.Phone>
                                <OnIdiom.Tablet>
                                    <OnPlatform x:TypeArguments="Font" iOS="23" Android="23"  />
                                </OnIdiom.Tablet>
                            </OnIdiom>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="TextColor" Value="#770754" />
                    <Setter Property="FontAttributes" Value="None" />
    
                </Style>
    
  • voidstreamvoidstream FRMember ✭✭✭

    @JoeManke said:
    Type names are case-sensitive, even in XAML. It's OnPlatform, not OnPlatForm (no capital F).

    Thanks... I'm mad :neutral:

  • ChaseFlorellChaseFlorell CAInsider, University mod

    Also note that this is a deprecated API and will eventually be removed

    <OnPlatform x:Key="FormLabelStyleMargin" 
                            x:TypeArguments="Thickness"
                            WinPhone="0,10,0,-10"
                            Android="0,10,0,-10"
                            iOS="0,10,0,2"/>
    

    You'll want to use this instead

    <OnPlatform x:Key="FormLabelStyleMargin" 
                            x:TypeArguments="Thickness">
        <On Platform="WinPhone" Value="0,10,0,-1" />
        <On Platform="Android" Value="0,10,0,-10" />
        <On Platform="iOS" Value="0,10,0,2" />
    </OnPlatform>
    
  • voidstreamvoidstream FRMember ✭✭✭

    @ChaseFlorell said:
    Also note that this is a deprecated API and will eventually be removed

    <OnPlatform x:Key="FormLabelStyleMargin" 
                            x:TypeArguments="Thickness"
                            WinPhone="0,10,0,-10"
                            Android="0,10,0,-10"
                            iOS="0,10,0,2"/>
    

    You'll want to use this instead

    <OnPlatform x:Key="FormLabelStyleMargin" 
                            x:TypeArguments="Thickness">
        <On Platform="WinPhone" Value="0,10,0,-1" />
        <On Platform="Android" Value="0,10,0,-10" />
        <On Platform="iOS" Value="0,10,0,2" />
    </OnPlatform>
    

    Deprecated? Really? Thanks you :smile:

  • NMackayNMackay GBInsider, University ✭✭✭✭✭

    <On Platform="WinPhone" Value="0,10,0,-1" />

    That platform is well and truly deprecated seeing as MS have killed it off :blush:

  • voidstreamvoidstream FRMember ✭✭✭

    @NMackay said:
    <On Platform="WinPhone" Value="0,10,0,-1" />

    That platform is well and truly deprecated seeing as MS have killed it off :blush:

    You disturb me, which is the good syntax?

    Case 1 :

    <OnPlatform x:Key="FormLabelStyleMargin" 
                            x:TypeArguments="Thickness"
                            WinPhone="0,10,0,-10"
                            Android="0,10,0,-10"
                            iOS="0,10,0,2"/>
    

    Case 2

    <OnPlatform x:Key="FormLabelStyleMargin" 
                            x:TypeArguments="Thickness">
        <On Platform="WinPhone" Value="0,10,0,-1" />
        <On Platform="Android" Value="0,10,0,-10" />
        <On Platform="iOS" Value="0,10,0,2" />
    </OnPlatform>
    

    Case 3

    <OnPlatform x:TypeArguments="Thickness">
        <OnPlatform.iOS>0,20,0,0</OnPlatform.iOS>
    </OnPlatform>
    
  • NMackayNMackay GBInsider, University ✭✭✭✭✭
    edited October 20

    @voidstream

    Sorry, was been sarcastic, the answer from @ChaseFlorell is correct, I was just referring to MS killing of Windows Phone for good, it's still supported but it's a dead as a mobile platform.

    I think from 2.4.0 onwards your supposed to use UWP in OnPlatform

                   <RowDefinition x:Name="RowAdvancedFilters">
                        <RowDefinition.Height>
                            <OnPlatform x:TypeArguments="GridLength">
                                <On Platform="iOS">130</On>
                                <On Platform="Android">120</On>
                                <On Platform="UWP">110</On>
                            </OnPlatform>
                        </RowDefinition.Height>
                    </RowDefinition>
    
  • voidstreamvoidstream FRMember ✭✭✭

    @NMackay said:
    @voidstream

    Sorry, was been sarcastic, the answer from @ChaseFlorell is correct, I was just referring to MS killing of Windows Phone for good, it's still supported but it's a dead as a mobile platform.

    I think from 2.4.0 onwards your supposed to use UWP in OnPlatform

                   <RowDefinition x:Name="RowAdvancedFilters">
                        <RowDefinition.Height>
                            <OnPlatform x:TypeArguments="GridLength">
                                <On Platform="iOS">130</On>
                                <On Platform="Android">120</On>
                                <On Platform="UWP">110</On>
                            </OnPlatform>
                        </RowDefinition.Height>
                    </RowDefinition>
    

    Ok thanks :smile:

  • ChaseFlorellChaseFlorell CAInsider, University mod

    @NMackay said:
    @voidstream

    Sorry, was been sarcastic, the answer from @ChaseFlorell is correct, I was just referring to MS killing of Windows Phone for good, it's still supported but it's a dead as a mobile platform.

    I think from 2.4.0 onwards your supposed to use UWP in OnPlatform

                   <RowDefinition x:Name="RowAdvancedFilters">
                        <RowDefinition.Height>
                            <OnPlatform x:TypeArguments="GridLength">
                                <On Platform="iOS">130</On>
                                <On Platform="Android">120</On>
                                <On Platform="UWP">110</On>
                            </OnPlatform>
                        </RowDefinition.Height>
                    </RowDefinition>
    

    Hahaha, yes.
    I simply translated his existing snippet into the new format.

    Technically speaking you can have this if you like too. It's perfectly valid, but you would need to register your own FUBAR as a platform

    <On Platform="FUBAR" Value="10,0,0,0">
    
Sign In or Register to comment.