public ListingListas() { Title = "Showing List"; NavigationPage.SetHasNavigationBar(this, true); listView = new ListView { RowHeight = 40, ItemTemplate = new DataTemplate(typeof(ItemCell)) }; listView.SeparatorVisibility = SeparatorVisibility.Default; listView.SeparatorColor = Color.White; listView.ItemSelected += (sender, e) => { var lista = (Lista)e.SelectedItem; var taskListing = new ListingTasks(lista.ID, true); Navigation.PushAsync(taskListing); }; var layout = new StackLayout(); if (Device.OS == TargetPlatform.WinPhone) { // WinPhone doesn't have the title showing layout.Children.Add(new Label { FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), FontAttributes = FontAttributes.Bold }); } layout.Children.Add(listView); layout.VerticalOptions = LayoutOptions.FillAndExpand; Content = layout; ToolbarItem tbi = null; if (Device.OS == TargetPlatform.iOS) { tbi = new ToolbarItem("+", null, () => { var lista = new Lista(); var listaCreatePage = new ListaCreatePage(); listaCreatePage.BindingContext = lista; Navigation.PushAsync(listaCreatePage); }, 0, 0); } if (Device.OS == TargetPlatform.Android) { // BUG: Android doesn't support the icon being null tbi = new ToolbarItem("+", "plus", () => { var lista = new Lista(); var listaCreatePage = new ListaCreatePage(); listaCreatePage.BindingContext = lista; Navigation.PushAsync(listaCreatePage); }, 0, 0); } if (Device.OS == TargetPlatform.WinPhone) { tbi = new ToolbarItem("Add", "add.png", () => { var lista = new Lista(); var listaCreatePage = new ListaCreatePage(); listaCreatePage.BindingContext = lista; Navigation.PushAsync(listaCreatePage); }, 0, 0); } ToolbarItems.Add(tbi); }
public ListaCreatePage() { this.SetBinding(ContentPage.TitleProperty, "Task"); Title = "List Creation Page"; NavigationPage.SetHasNavigationBar(this, true); var saveButton = new Button { Text = "Save" }; saveButton.IsEnabled = false; var createTaskButton = new Button { Text = "Create Tasks" }; createTaskButton.IsEnabled = false; var titleLabel = new Label { Text = "Title" }; var titleEntry = new Entry(); titleEntry.SetBinding(Entry.TextProperty, "Title"); titleEntry.TextChanged += (o, e) => { saveButton.IsEnabled = true; createTaskButton.IsEnabled = true; }; var detailLabel = new Label { Text = "Detail" }; var detailEntry = new Entry(); detailEntry.SetBinding(Entry.TextProperty, "Detail"); detailEntry.TextChanged += (o, e) => { saveButton.IsEnabled = true; createTaskButton.IsEnabled = true; }; var projectLabel = new Label { Text = "Project" }; var projectEntry = new Entry(); projectEntry.SetBinding(Entry.TextProperty, "Project"); projectEntry.TextChanged += (o, e) => { saveButton.IsEnabled = true; createTaskButton.IsEnabled = true; }; saveButton.Clicked += (sender, e) => { var lista = (Lista)BindingContext; lista.Created = DateTime.Now; App.Database.SaveLista(lista); Navigation.PopAsync(); }; createTaskButton.Clicked += (sender, e) => { var lista = (Lista)BindingContext; lista.Created = DateTime.Now; App.Database.SaveLista(lista); lista = (from listas in App.Database.getListas() select listas).LastOrDefault <Lista>(); var listingPage = new ListingTasks(lista.ID, false); listingPage.BindingContext = lista; Navigation.PushAsync(listingPage); }; var cancelButton = new Button { Text = "Cancel" }; cancelButton.Clicked += (sender, e) => { Navigation.PopAsync(); }; Content = new StackLayout { VerticalOptions = LayoutOptions.StartAndExpand, Padding = new Thickness(20), Children = { titleLabel, titleEntry, detailLabel, detailEntry, projectLabel, projectEntry, saveButton, createTaskButton , cancelButton } }; }