Skip to content

Instantly share code, notes, and snippets.

@Driv4r
Last active June 15, 2016 00:06
Show Gist options
  • Save Driv4r/744dee99fc0a497713afadda7a8249e0 to your computer and use it in GitHub Desktop.
Save Driv4r/744dee99fc0a497713afadda7a8249e0 to your computer and use it in GitHub Desktop.
Example for using basic, shared resources in xaml. Put this in App.xaml.
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Myproject.Pages.LoginPage" Padding="25, 20, 25, 10" BackgroundColor="{StaticResource defaultBackgroundColor}" Title="Sign In"> <ContentPage.Content> <StackLayout Padding="10,0,10,20" VerticalOptions="FillAndExpand"> <StackLayout x:Name="contentLayout" VerticalOptions="CenterAndExpand"> <Image Source="PPP_Logo.png"/> <Label Text="Email" TextColor="{StaticResource defaultLabelTextColor}" /> <Entry x:Name="emailEntry" /> <Label Text="Password" TextColor="{StaticResource defaultLabelTextColor}" /> <Entry x:Name="passwordEntry" IsPassword="true"/> <Button Text="Sign In" TextColor="{StaticResource defaultButtonTextColor}" Clicked="OnLoginButtonClicked" BackgroundColor="{StaticResource greenButtonBackgroundColor}"/> <ContentView Padding="0, 20"> <Label Text="Don't have an account?" x:Name="dontHaveAccountLbl" HorizontalTextAlignment="Center" TextColor="{StaticResource defaultLabelTextColor}" FontSize="{StaticResource smallFontSize}" ></Label> </ContentView> </StackLayout> </StackLayout> </ContentPage.Content> </ContentPage>
<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Myproject.App">
<Application.Resources>
<ResourceDictionary>
<!-- General Color-->
<Color x:Key="defaultGray">#979797</Color>
<!--Background Colors-->
<Color x:Key="defaultBackgroundColor">#FFFFFF</Color>
<!-- Label Colors-->
<Color x:Key="defaultLabelTextColor">#979797</Color>
<Color x:Key="blackLabelTextColor">#000000</Color>
<Color x:Key="whiteLabelTextColor">#FFFFFF</Color>
<Color x:Key="blueLabelBackgroundColor">#4A90E2</Color>
<!-- Entry Colors-->
<Color x:Key="defaultEntryTextColor">#979797</Color>
<Color x:Key="defaultEntryPlaceholderColor">#979797</Color>
<Color x:Key="defaultEntryBackgroundColor">#FFFFFF</Color>
<!-- Button Colors-->
<Color x:Key="greenButtonBackgroundColor">#7ED321</Color>
<Color x:Key="blueButtonBackgroundColor">#3AA2E1</Color>
<Color x:Key="googleButtonBackgroundColor">#DD4B39</Color>
<Color x:Key="facebookButtonBackgroundColor">#3B5999</Color>
<Color x:Key="cancelButtonBackgroundColor">#E40613</Color>
<Color x:Key="defaultButtonTextColor">#FFFFFF</Color>
<!-- Font Sizes-->
<x:Double x:Key="xlargeFontSize">30</x:Double>
<x:Double x:Key="largeFontSize">24</x:Double>
<x:Double x:Key="smallFontSize">12</x:Double>
<x:Double x:Key="xsmallFontSize">10</x:Double>
</ResourceDictionary>
</Application.Resources>
</Application>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment