Ooui-tws-port/Samples/TipCalc/TipCalcPage.xaml

56 lines
3.5 KiB
Plaintext
Raw Normal View History

2017-12-12 20:25:56 +00:00
<?xml version="1.0" encoding="utf-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TipCalc"
x:Class="TipCalc.TipCalcPage">
<ContentPage.Padding>
<OnPlatform x:TypeArguments="Thickness">
<On Platform="iOS" Value="5, 20, 5, 0" />
<On Platform="Android, UWP, WinRT, WinPhone" Value="5, 0, 5, 0" />
</OnPlatform>
</ContentPage.Padding>
<ContentPage.Resources>
<ResourceDictionary>
<local:TipCalcModel x:Key="model" TipPercent="15" />
<local:DoubleToStringConverter x:Key="stringConverter" />
<local:DoubleRoundingConverter x:Key="roundConverter" />
</ResourceDictionary>
</ContentPage.Resources>
<Grid BindingContext="{StaticResource model}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Row 0 -->
<Label Text="Food &amp; Drink:" Grid.Row="0" Grid.Column="0" Font="Large" HorizontalTextAlignment="End" VerticalTextAlignment="Center" />
<Entry Grid.Row="0" Grid.Column="1" Keyboard="Numeric" Placeholder="Subtotal" Text="{Binding SubTotal, &#xA; Converter={StaticResource stringConverter}}" />
<!-- Row 1 -->
<Label Text="Total after Tax:" Grid.Row="1" Grid.Column="0" Font="Large" HorizontalTextAlignment="End" VerticalTextAlignment="Center" />
<Entry Grid.Row="1" Grid.Column="1" Keyboard="Numeric" Placeholder="Receipt total" Text="{Binding PostTaxTotal,&#xA; Converter={StaticResource stringConverter}}" />
<!-- Row 2 -->
<Label Text="Tip Percent:" Grid.Row="2" Grid.Column="0" Font="Large" HorizontalTextAlignment="End" VerticalTextAlignment="Center" />
<Entry Grid.Row="2" Grid.Column="1" Keyboard="Numeric" Text="{Binding TipPercent,&#xA; Converter={StaticResource stringConverter}}" />
<!-- Row 3 -->
<Slider Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Minimum="0" Maximum="100" Value="{Binding TipPercent,&#xA; Mode=TwoWay,&#xA; Converter={StaticResource roundConverter},&#xA; ConverterParameter=0.5}" />
<!-- Row 4 -->
<Label Text="Tip Amount:" Grid.Row="4" Grid.Column="0" Font="Large" HorizontalTextAlignment="End" VerticalTextAlignment="Center" />
<ContentView BackgroundColor="#40808080" Grid.Row="4" Grid.Column="1" Padding="10, 10, 40, 10">
<Label Text="{Binding TipAmount,&#xA; StringFormat='{0:C}'}" Font="Large" HorizontalTextAlignment="End" />
</ContentView>
<!-- Row 5 -->
<Label Text="Total:" Grid.Row="5" Grid.Column="0" Font="Large" HorizontalTextAlignment="End" VerticalTextAlignment="Center" />
<ContentView BackgroundColor="#40808080" Grid.Row="5" Grid.Column="1" Padding="10, 10, 40, 10">
<Label Text="{Binding Total, &#xA; StringFormat='{0:C}'}" Font="Large" HorizontalTextAlignment="End" />
</ContentView>
</Grid>
</ContentPage>