Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created November 21, 2019 13:28
Show Gist options
  • Save icebeam7/c9ef10c1876f586ae3642d142977b973 to your computer and use it in GitHub Desktop.
Save icebeam7/c9ef10c1876f586ae3642d142977b973 to your computer and use it in GitHub Desktop.
MVVMDemo: ProductView.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"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:vm="clr-namespace:MVVMDemo.ViewModels"
x:Class="MVVMDemo.Views.ProductView">
<ContentPage.BindingContext>
<vm:ProductViewModel/>
</ContentPage.BindingContext>
<ContentPage.Content>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Text="Product Name"/>
<Entry Grid.Row="0" Grid.Column="1" Text="{Binding Name}"/>
<Label Grid.Row="1" Grid.Column="0" Text="Product Price"/>
<Entry Grid.Row="1" Grid.Column="1" Text="{Binding Price}" Keyboard="Numeric"/>
<Label Grid.Row="2" Grid.Column="0" Text="Product Availability"/>
<Switch Grid.Row="2" Grid.Column="1" IsToggled="{Binding IsAvailable}" />
<Button Grid.Row="3" Grid.Column="0" Text="Send Email" Command="{Binding SendEmailCommand}"/>
<Button Grid.Row="3" Grid.Column="1" Text="Clear Info" Command="{Binding ClearCommand}"/>
<StackLayout Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2">
<Label Text="{Binding Name, StringFormat='Product Name: {0}'}"/>
<Label Text="{Binding Price, StringFormat='Product Price: {0:N2}'}"/>
<CheckBox IsChecked="{Binding IsAvailable}"/>
</StackLayout>
</Grid>
</ContentPage.Content>
</ContentPage>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment