Forms and Setting Pages Cheat Sheet
Forms and Setting Pages Cheat Sheet
Switch
For capturing a boolean value.
<Editor />
1
Forms and Setting Pages By: Mosh Hamedani
Picker
For allowing the user to select from a short list of items. Prefer to use picker with
navigation technique.
In XAML:
<Picker>
<Picker.ItemsSource>
<x:String>…</x:String>
<x:String>…</x:String>
</Picker.ItemsSource>
</Picker>
In code-behind:
2
Forms and Setting Pages By: Mosh Hamedani
<ContentPage xmlns:sys=“clr-namespace:System;assembly=mscorlib”>
<DatePicker Date=“{x:Static sys:DateTime.Today}” />
</ContentPage>
TableView
<TableView Intent=“Form”>
<TableRoot>
<TableSection Title=“Section1”>
… (one or more cells)
</TableSection>
</TableRoot>
</TableView>
Cell types:
• TextCell
• ImageCell
• EntryCell
• SwitchCell
• ViewCell (for implementing custom cells)
3
Forms and Setting Pages By: Mosh Hamedani
Bindable Properties
<ViewCell Tapped=“Handle_Tapped”>
<StackLayout>
<Label … />
<Label x:Name=“contactMethod” … />
</StackLayout>
</ViewCell>
4
Forms and Setting Pages By: Mosh Hamedani
In code-behind:
void Handle_Tapped(…)
{
var page = new ContactMethodsPage();
page.ContactMethods.ItemSelected += (source, args) =>
{
contactMethod.Text = args.SelectedItem.ToString();
Navigation.PopAsync();
};
Navigation.PushAsync(page);
}
This requires exposing the ListView in ContactDetails page via a public property.