Skip to content

Instantly share code, notes, and snippets.

@mshenoy83
Last active March 28, 2017 22:04
Show Gist options
  • Save mshenoy83/dda54b0456fcd5a339dd1fc7eb4ef9bc to your computer and use it in GitHub Desktop.
Save mshenoy83/dda54b0456fcd5a339dd1fc7eb4ef9bc to your computer and use it in GitHub Desktop.
Sample Xaml Binding
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="CustomerApp.Views.Login"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:behaviors="clr-namespace:CustomerApp.Infrastructure.Behaviors;assembly=CustomerApp"
xmlns:c="clr-namespace:CustomerApp.Infrastructure.Converters;assembly=CustomerApp"
Style="{StaticResource SignUpScreen}">
<ContentPage.Resources>
<ResourceDictionary>
<c:DictionaryItemConverter x:Key="DictBool" />
</ResourceDictionary>
</ContentPage.Resources>
<StackLayout
Margin="10,0,10,0"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<StackLayout
Margin="0,60,0,0"
HorizontalOptions="Center"
VerticalOptions="StartAndExpand">
<Image Source="LoginLogo.png" WidthRequest="200" />
</StackLayout>
<StackLayout Style="{StaticResource NoSpaceStack}" VerticalOptions="EndAndExpand">
<StackLayout>
<Entry
HorizontalOptions="FillAndExpand"
Keyboard="Chat"
Style="{StaticResource SignUpTextBoxDefault}"
Text="{Binding UserName}">
<Entry.Behaviors>
<behaviors:TextChangedBehavior Command="{Binding OnTextChangedCommand}" EventName="TextChanged" />
<behaviors:TextChangedBehavior
Command="{Binding OnNextCommand}"
CommandParameter="{Binding ., Source={x:Reference PasswordEntry}}"
EventName="Completed" />
</Entry.Behaviors>
</Entry>
</StackLayout>
<StackLayout>
<StackLayout
HorizontalOptions="FillAndExpand"
Orientation="Horizontal"
Style="{StaticResource NoSpaceStack}">
<Entry
HorizontalOptions="FillAndExpand"
IsPassword="True"
Keyboard="Chat"
Style="{StaticResource SignUpTextBoxDefault}"
Text="{Binding Password}">
<Entry.Behaviors>
<behaviors:TextChangedBehavior Command="{Binding OnTextChangedCommand}" EventName="TextChanged" />
<behaviors:TextChangedBehavior
Command="{Binding OnNextCommand}"
CommandParameter="{Binding ., Source={x:Reference BtnLogin}}"
EventName="Completed" />
</Entry.Behaviors>
</Entry>
</StackLayout>
</StackLayout>
<StackLayout.Margin>
<OnPlatform
x:TypeArguments="Thickness"
Android="0,0,0,0"
iOS="0,5,0,5" />
</StackLayout.Margin>
<controls:Checkbox
CheckedImage="selectedcheckbox.png"
IsChecked="{Binding RememberPassword, Mode=TwoWay}"
UnCheckedImage="emptycheckbox.png"
VerticalOptions="Center">
<controls:Checkbox.HeightRequest>
<OnPlatform
x:TypeArguments="x:Double"
Android="80"
iOS="20" />
</controls:Checkbox.HeightRequest>
</controls:Checkbox>
<Label
Style="{StaticResource SignUpLabelSpelDefault}"
Text="Remember password"
VerticalOptions="Center"
VerticalTextAlignment="Center" />
<Label
HorizontalTextAlignment="Center"
Style="{StaticResource SignUpLabelSpelBlue}"
Text="Forgot/Reset"
VerticalTextAlignment="Center">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ResetMeCommand}" />
</Label.GestureRecognizers>
</Label>
</StackLayout>
<StackLayout>
<Button
BorderRadius="0"
Command="{Binding OnLoginCommand}"
HorizontalOptions="FillAndExpand"
IsEnabled="{Binding EnableLogin}"
Style="{StaticResource BlueButtonSofia}"
Text="Login" />
</StackLayout>
<StackLayout
Margin="0,20,0,20"
HorizontalOptions="Center"
Orientation="Horizontal">
<Label
HorizontalTextAlignment="Center"
Style="{StaticResource SignUpLabelSpelDefault}"
Text="New to Openpay?" />
<Label
HorizontalTextAlignment="Center"
Style="{StaticResource SignUpLabelSpelBlue}"
Text="Create account">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding SignUpCommand}" />
</Label.GestureRecognizers>
</Label>
</StackLayout>
</StackLayout>
</StackLayout>
</ContentPage>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment