public void Init() { VM.BindData(); var tableSection = new TableSection(""); tableSection.Add(new JL_TextCell("Sted", VM.CurrentJakt.Title, StedCell_OnTapped)); tableSection.Add(new JL_ImageCell("Jaktbilde", VM.CurrentJakt.Image, ImageCell_OnTapped)); tableSection.Add(new JL_TextCell("Dato", VM.CurrentJakt.DatoFraTil, DateCell_OnTapped)); tableSection.Add(new JL_TextCell("Posisjon", VM.CurrentJakt.Position, Posisjon_OnTapped)); tableSection.Add(new JL_TextCell("Jegere på jaktlaget", VM.CurrentJakt.JegereInJakt, Jegere_OnTapped)); tableSection.Add(new JL_TextCell("Hunder på jaktlaget", VM.CurrentJakt.DogsInJakt, Dogs_OnTapped)); tableSection.Add(new JL_TextCell("Notater", VM.CurrentJakt.Notes, NoteCell_OnTapped)); tableSection.Add(new JL_TextCell("Se alle loggføringer på kartet", ">>", ViewLogsOnMap_OnTapped)); Content = new TableViewJL { HasUnevenRows = true, Root = new TableRoot { tableSection, new TableSection() { new JL_ButtonCell("Slett jakt", ButtonDelete_OnClicked) }, }, }; }
public void Init() { VM.BindData(); var editJaktBtn = new Image() { Source = "more.png", HeightRequest = 40, WidthRequest = 40, HorizontalOptions = LayoutOptions.EndAndExpand }; var dateLabel = new Label() { FontSize = 12 }; var titleLabel = new Label() { FontSize = 16 }; var circleImage = new CircleImage() { VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Start, BorderThickness = 2, BorderColor = Color.White, HeightRequest = 70, WidthRequest = 70, Aspect = Aspect.AspectFill }; var headerTextLayout = new StackLayout() { VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.StartAndExpand, Children = { dateLabel, titleLabel } }; dateLabel.SetBinding(Label.TextProperty, new Binding("CurrentJakt.DatoFraTil")); titleLabel.SetBinding(Label.TextProperty, new Binding("CurrentJakt.Title")); circleImage.SetBinding(CircleImage.SourceProperty, new Binding("CurrentJakt.Image")); headerTextLayout.SetBinding(StackLayout.IsVisibleProperty, new Binding("IsLoadingPosition", converter: new InverseBooleanConverter())); PositionActivityIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, new Binding("IsLoadingPosition")); var jaktSummary = new StackLayout() { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.Fill, Padding = 5, GestureRecognizers = { new TapGestureRecognizer { Command = new Command(() => Navigation.PushAsync(new JaktPage(VM.CurrentJakt))), }, }, Children = { circleImage, headerTextLayout, PositionActivityIndicator, editJaktBtn } }; ListView lv = new ListView(); lv.HorizontalOptions = LayoutOptions.FillAndExpand; lv.VerticalOptions = LayoutOptions.FillAndExpand; lv.SetBinding(ListView.ItemsSourceProperty, new Binding("ItemCollection")); lv.ItemSelected += (sender, e) => { if (e.SelectedItem != null) { Navigation.PushAsync(new LoggPage((Logg)e.SelectedItem), true); ((ListView)sender).SelectedItem = null; } }; //Remember to remove this event handler on dispoing of the page; DataTemplate dt = new DataTemplate(typeof(CircleImageCell)); dt.SetBinding(CircleImageCell.TextProperty, new Binding("Title")); dt.SetBinding(CircleImageCell.DetailProperty, new Binding("Details")); dt.SetBinding(CircleImageCell.ImageSourceProperty, new Binding("Image")); lv.ItemTemplate = dt; if (VM.ItemCollection.Any()) { Content = new StackLayout() { Padding = 5, Children = { jaktSummary, lv } }; } else { var btn = new Button() { Text = "Opprett første loggføring", BackgroundColor = Color.FromHex("#74B058") }; btn.Clicked += delegate(object sender, EventArgs args) { var logg = VM.CreateLogg(); Navigation.PushAsync(new LoggPage(logg), true); }; Content = new StackLayout() { Children = { jaktSummary, btn } }; } }