Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Xamarin Forms in Action - Brief Overview

Avatar for Royce Mars Royce Mars
January 07, 2017

Xamarin Forms in Action - Brief Overview

15 minutes presentation about Xamarin basics

Avatar for Royce Mars

Royce Mars

January 07, 2017
Tweet

More Decks by Royce Mars

Other Decks in Programming

Transcript

  1. Xamarin Forms XAML <ContentPage.Content> <StackLayout Orientation="Vertical" VerticalOptions="FillAndExpand"> <Label x:Name="label" Text="List

    of medicines” HorizontalOptions="Center" /> <StackLayout Orientation="Horizontal"> <Entry x:Name="nameEntry" HorizontalOptions="FillAndExpand" /> <DatePicker x:Name="datePicker" HorizontalOptions="End"/> <Button x:Name="addButton" Text="Add" Clicked="add" HorizontalOptions="End" /> <Button x:Name="scanButton" Text="Scan" Clicked="scan" HorizontalOptions="End" /> </StackLayout> <ListView x:Name="list" VerticalOptions="FillAndExpand"> <ListView.ItemTemplate> <DataTemplate> <TextCell Text="{Binding Name}" Detail="{Binding ExpireDate, StringFormat='Expires: {0:MM-dd-yy}'}"> <TextCell.ContextActions>
  2. Xamarin Forms Bindings <ListView x:Name="list" VerticalOptions="FillAndExpand"> <ListView.ItemTemplate> <DataTemplate> <TextCell Text="{Binding

    Name}" Detail="{Binding ExpireDate, StringFormat='Expires: {0:MM-dd-yy}'}"> <TextCell.ContextActions> <MenuItem Clicked="onDelete" CommandParameter="{Binding .}" Text="Delete" IsDestructive="True" /> </TextCell.ContextActions> </TextCell> </DataTemplate> </ListView.ItemTemplate> </ListView> </StackLayout> </ContentPage.Content>
  3. Platform Specific. Interface Implementation [assembly: Xamarin.Forms.Dependency (typeof (NotificationHelperImpl))] namespace MedChestAssistant.iOS

    { public class NotificationHelperImpl: INotificationHelper { #region INotificationHelper implementation public void notify (string message) { var notification = new UILocalNotification(); // set notification params … UIApplication.SharedApplication.ScheduleLocalNotification(notification); } #endregion public NotificationHelperImpl () { } } }
  4. iOS-specific notifications setup if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) { var notificationSettings

    = UIUserNotificationSettings.GetSettingsForTypes ( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null ); app.RegisterUserNotificationSettings (notificationSettings); }