Xamarin : Resource Contents - Stylesheet



Xamarin : Resource Contents - Stylesheet


Design Page

<ContentPage.Resources>
    <ResourceDictionary>
      <Style x:Key="ColorfullLabel" TargetType="Label">
        <Setter Property="TextColor" Value="Red"></Setter>
        <Setter Property="BackgroundColor" Value="Yellow"></Setter>
      </Style>
      <Style x:Key="lblMargin" TargetType="Label">
        <Setter Property="Margin" Value="20"></Setter>
        <Setter Property="FontSize" Value="20"></Setter>
      </Style>
      <Style x:Key="btnMargin" TargetType="Button">
        <Setter Property="Margin" Value="20"></Setter>
        <Setter Property="FontSize" Value="20"></Setter>
        <Setter Property="Rotation" Value="20"></Setter>
        <Setter Property="BorderWidth" Value="20"></Setter>
      </Style>
    </ResourceDictionary>
  </ContentPage.Resources>
  
  <StackLayout Orientation="Vertical">

    <Label Text="Different color"
           Style="{StaticResource ColorfullLabel}"></Label>

    <Label Text="Font Size"
           FontSize="20"></Label>

    <Label Text="Margin"
           Style="{StaticResource lblMargin}"></Label>

    <Label Text="Italic"
           FontAttributes="Italic"></Label>

    <Label Text="Left Justified"
           HorizontalTextAlignment="End"
           FontSize="Large"></Label>

    <Label Text="Hello, World!"
         VerticalOptions="Start"
         HorizontalTextAlignment="Center"
         Rotation="-15"
         IsVisible="true"
         FontSize="Large"
         FontAttributes="Bold"
         TextColor="Blue" />

    <Button Text="Verticle Button"
        Style="{StaticResource btnMargin}">
    </Button>

  </StackLayout>

No comments:

Post a Comment