locked
Built-in Device.Styles in XAML not working? RRS feed

  • Question

  • User23807 posted

    Hi,

    I'm trying to use the built-in Device.Styles in XAML like

    <Label Text="Some text" Style="{x:DynamicResource CaptionStyle}"/>

    But no matter what style I use, it's not working. What I'm missing?

    Wednesday, January 14, 2015 4:27 PM

All replies

  • User56293 posted

    Hi,

    Not sure if this detail is relevant :-

    Using DynamicResource allows Xamarin.Forms built-in styles to support iOS 8 Dynamic Type so that when users change their Accessibility settings for text size, Xamarin.Forms applications that use these styles will adjust accordingly.

    developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/styles/

    Thanks

    Paul Diston

    Wednesday, January 14, 2015 4:35 PM
  • User23807 posted

    Hi Paul, I already looked at that sample and started there. This Accessibility settings should only affect iOS but it does not work on all 3 platforms.

    The only difference is that I have to use an additional namespace x: xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

    Wednesday, January 14, 2015 5:11 PM
  • User23807 posted

    The same happens in code:

               Content = new StackLayout
                    {
                       VerticalOptions = LayoutOptions.Center,
                       Children = {
                       new Label {
                     XAlign = TextAlignment.Center,
                     Text = "Welcome to Xamarin Forms!"
                      },
                          new Label
                          {
                             Text = "BodyStyle",
                             Style = Device.Styles.BodyStyle
                          },
                          new Label
                          {
                             Text = "CaptionStyle",
                             Style = Device.Styles.CaptionStyle
                          },
                          new Label
                          {
                             Text = "ListItemDetailTextStyle",
                             Style = Device.Styles.ListItemDetailTextStyle
                          },
                          new Label
                          {
                             Text = "ListItemTextStyle",
                             Style = Device.Styles.ListItemTextStyle
                          },
                          new Label
                          {
                             Text = "SubtitleStyle",
                             Style = Device.Styles.SubtitleStyle
                          },
                          new Label
                          {
                             Text = "TitleStyle",
                             Style = Device.Styles.TitleStyle
                          },
                }
              }
    

    Results in

    Thursday, January 15, 2015 10:15 AM
  • User62190 posted

    Same issue here.

    Thursday, January 22, 2015 10:05 AM
  • User23807 posted

    Working in 1.3.2-pre1

    Friday, January 23, 2015 8:03 AM
  • User62190 posted

    for me it only works in iOS

    Tuesday, January 27, 2015 7:27 PM
  • User23807 posted

    It works in code, the sample above now looks like this (WP, iOS, Android):

    Wednesday, January 28, 2015 11:06 AM
  • User62190 posted

    this is weird, for iOS it works perfectly for me. on android somehow not. I do set it in code. are you using the xamarin android player?

    Wednesday, January 28, 2015 2:43 PM
  • User23807 posted

    That was tested on a physical device.

    Wednesday, January 28, 2015 2:44 PM