Global Styles with ONIDIOM not working on recent updates?

SuperCDSuperCD USMember ✭✭

I recently upgraded my forms version for from 2.5.91635 to XF 3.0 and the global styles which I have defined stopped working . However styles with OnPlatform are working and styles which are having OnIdiom in it , its not working. I'm currently using .NEt standard?
Any idea?

Tagged:

Answers

  • JoeMankeJoeManke USMember ✭✭✭✭✭

    Could you post an example of one of your styles that is no longer working?

  • SuperCDSuperCD USMember ✭✭
    edited May 2018
                <Style x:Key="XFLabel" BasedOn="{StaticResource BaseLabelText}"
                                TargetType="Label">
                                <Setter Property="TextColor" Value="White" />
                            </Style>
    
    and base style is : 
    
    
    
    `<Style x:Key="BaseLabelText" TargetType="Label">
                    <Setter Property="FontSize">
                        <Setter.Value>
                            <OnIdiom
                                x:TypeArguments="x:String"
                                Phone="Medium"
                                Tablet="28" />
                        </Setter.Value>
                    </Setter>
                </Style>`
    
  • SuperCDSuperCD USMember ✭✭
    edited May 2018

    Added

  • JoeMankeJoeManke USMember ✭✭✭✭✭

    My guess is that your problem is more related to mixing NamedSize and a double and handing a string to a property expecting a double.

  • GuidoNeele.6288GuidoNeele.6288 USMember ✭✭
    edited May 2018

    I'm experiencing the same with OnIdiom in global styles. I'm also using Xamarin Forms 3.0.

    If I use the following code in app.xaml the default linear layout is used on my laptop.

    <OnIdiom x:Key="SFListViewLayoutManager" x:TypeArguments="sflistview:LayoutBase">
        <OnIdiom.Phone>
            <sflistview:LinearLayout />
        </OnIdiom.Phone>
        <OnIdiom.Tablet>
            <sflistview:GridLayout SpanCount="2" />
        </OnIdiom.Tablet>
        <OnIdiom.Desktop>
            <sflistview:GridLayout SpanCount="3" />
        </OnIdiom.Desktop>
    </OnIdiom>
    

    If I use the same value directly on the listview in my contentpage I get a grid layout in 3 columns

    <sflistview:SfListView.LayoutManager>
        <OnIdiom x:TypeArguments="sflistview:LayoutBase">
            <OnIdiom.Phone>
                <sflistview:LinearLayout />
            </OnIdiom.Phone>
            <OnIdiom.Tablet>
                <sflistview:GridLayout SpanCount="2" />
             </OnIdiom.Tablet>
             <OnIdiom.Desktop>
                 <sflistview:GridLayout SpanCount="3" />
             </OnIdiom.Desktop>
         </OnIdiom>
    </sflistview:SfListView.LayoutManager>
    

    Got the same thing happening with the thickness for setting item spacing.

  • Steve_hawkinsSteve_hawkins GBUniversity ✭✭

    the namedSize styles have stopped working since 2.5. I've tested using the following global styles:






    <Setter.Value>








    </Setter.Value>

            <Style x:Key="ShowButtonFlat2" TargetType="Button">
                <Setter Property="BackgroundColor" Value="Black" />
                <Setter Property="TextColor" Value="White" />
                <Setter Property="FontSize">
                    <Setter.Value>
                        <OnIdiom x:TypeArguments="x:String" Tablet="Medium" Phone="Large" />
                    </Setter.Value>
                </Setter>
            </Style>
    
            <Style x:Key="ShowButtonFlat3" TargetType="Button">
                <Setter Property="BackgroundColor" Value="Black" />
                <Setter Property="TextColor" Value="White" />
                <Setter Property="FontSize">
                    <Setter.Value>
                        <OnPlatform x:TypeArguments="x:String" >
                            <On Platform="Android" >
                                Large
                            </On>
                            <On Platform="iOS" >
                                Large
                            </On>
                        </OnPlatform>
                    </Setter.Value>
                </Setter>
            </Style>
    
            <Style x:Key="ShowButtonFlat4" TargetType="Button">
                <Setter Property="BackgroundColor" Value="Black" />
                <Setter Property="TextColor" Value="White" />
                <Setter Property="FontSize">
                    <Setter.Value>
                        <OnPlatform x:TypeArguments="x:Double" >
                            <On Platform="Android" >
                               25
                            </On>
                            <On Platform="iOS" >
                                25
                            </On>
                        </OnPlatform>
                    </Setter.Value>
                </Setter>
            </Style>
    
            <Style x:Key="ShowButtonFlat5" TargetType="Button">
                <Setter Property="BackgroundColor" Value="Black" />            
                <Setter Property="TextColor" Value="White" />
                <Setter Property="FontSize">
                    <Setter.Value>
                        <OnPlatform x:TypeArguments="x:Double" >
                            <On Platform="Android" >
                                <OnIdiom x:TypeArguments="x:Double" Tablet="25" Phone="25" />
                            </On>
                            <On Platform="iOS" >
                                <OnIdiom x:TypeArguments="x:Double" Tablet="25" Phone="25" />
                            </On>
                        </OnPlatform>
                    </Setter.Value>
                </Setter>
            </Style>
    
        </ResourceDictionary>
    

    Only the styles with Double fontsize work on the text. (note all the other style settings work fine only issue is fontsize).

    so the styles : ShowButtonFlat4 and ShowButtonFlat5
    work as expected and the other do not. They work fine with xamarin forms less than 2.5

  • Steve_hawkinsSteve_hawkins GBUniversity ✭✭

    I just created my own namedsize matching the native sizes and added to the app.xaml file and change styles to use that and it works fine

  • SteeveDessSteeveDess Member ✭✭

    I guys,

    I have the same problem. I just upgrade to the last version (3.2.0.839982) of Xamafin.Forms nuget package on .Net c# , all my OnIdiom in global style don't work anymore.
    This one for example :

    <Style x:Key="layoutMenuPrincipal" TargetType="StackLayout">
                    <Setter Property="VerticalOptions" Value="FillAndExpand" />
                    <Setter Property="HorizontalOptions" Value="FillAndExpand" />
                    <Setter Property="Orientation">
                        <Setter.Value>
                            <OnIdiom x:TypeArguments="x:String" Tablet="Horizontal" Phone="Vertical" Desktop="Horizontal"/>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="Padding">
                        <Setter.Value>
                            <OnIdiom x:TypeArguments="Thickness" Tablet="100, 10, 100, 0" Phone="0, 0, 0, 0" Desktop="150, 100, 150, 0"/>
                        </Setter.Value>
                    </Setter>
                </Style>
    

    What's the solution ?

    Steeve

Sign In or Register to comment.