public AddRatingView(Cheese cheese) { _viewModel = new AddRatingViewModel (cheese, this); BindingContext = _viewModel; var cheeseName = new Label (); cheeseName.Text = string.Format ("The cheese name is {0}", _viewModel.RatingToAdd.CheeseName); var dairyName = new Label () { Text = "Dairy Name" }; dairyName.Text = string.Format ("The dairy name is {0}", _viewModel.RatingToAdd.DairyName); var ratingLabel = new Label () { Text = "Rating:" }; var notesLabel = new Label () { Text = "Notes:" }; var ratingView = new RatingView (true); ratingView.SetBinding (RatingView.WedgeRatingProperty, "RatingToAdd.WedgeRating"); var notesEntry = new Entry () { }; notesEntry.SetBinding (Entry.TextProperty, "RatingToAdd.Notes"); var entryGrid = new Grid () { ColumnSpacing = 0, RowSpacing = 2, VerticalOptions = LayoutOptions.Start }; entryGrid.RowDefinitions.Add (new RowDefinition (){ Height = GridLength.Auto }); entryGrid.RowDefinitions.Add (new RowDefinition () { Height = GridLength.Auto }); entryGrid.ColumnDefinitions.Add (new ColumnDefinition () { Width = GridLength.Auto }); entryGrid.ColumnDefinitions.Add (new ColumnDefinition (){ Width = new GridLength (1, GridUnitType.Star) }); entryGrid.Children.Add (ratingLabel, 0, 0); entryGrid.Children.Add (ratingView, 1, 0); entryGrid.Children.Add (notesLabel, 0, 1); entryGrid.Children.Add (notesEntry, 1, 1); var saveButton = new Button () { Text = "Save", FontAttributes = FontAttributes.Bold, BackgroundColor = CheeseColors.RED, TextColor = Color.White, FontSize = 18, BorderRadius = 0 }; saveButton.Command = _viewModel.AddRatingCommand; var cancelButton = new Button () { Text = "Cancel", FontAttributes = FontAttributes.Bold, BackgroundColor = CheeseColors.GRAY, TextColor = Color.White, FontSize = 18, BorderRadius = 0 }; var grid = new Grid () { RowDefinitions = { new RowDefinition { Height = new GridLength (40, GridUnitType.Star) } }, ColumnDefinitions = { new ColumnDefinition () { Width = new GridLength (.5, GridUnitType.Star) }, new ColumnDefinition () { Width = new GridLength (.5, GridUnitType.Star) } }, Padding = new Thickness (0, 0, 0, 0), RowSpacing = 0, ColumnSpacing = 0 }; grid.Children.Add (saveButton, 0, 0); grid.Children.Add (cancelButton, 1, 0); cancelButton.Clicked += async (sender, e) => { await Navigation.PopAsync(true); }; var cameraImage = new FileImageSource (); cameraImage.File = "Camera.png"; var cameraButton = new Button () { Image = cameraImage, Text="Take Photo" }; cameraButton.Clicked += async (sender, e) => { var cv = new CameraView(); await Navigation.PushModalAsync(cv); }; var scroll = new ScrollView (); scroll.Content = new StackLayout { Children = { cheeseName, dairyName, entryGrid, cameraButton, grid } }; var headerImage = new Image { Source = "Rectangle1.png", Aspect = Aspect.AspectFill }; Content = new StackLayout() { Children = { headerImage, scroll } }; }
public CardView () { Grid grid = new Grid { Padding = new Thickness (0, 1, 1, 1), RowSpacing = 1, ColumnSpacing = 1, BackgroundColor = CheeseColors.WHITE, VerticalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = new GridLength (70, GridUnitType.Absolute) }, new RowDefinition { Height = new GridLength (30, GridUnitType.Absolute) } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength (4, GridUnitType.Absolute) }, new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength (150, GridUnitType.Absolute) }, } }; statusView = new CardStatusView (); detailsView = new CardDetailsView (); ratingView = new RatingView(false); // Add the colored status view content grid.Children.Add ( statusView , 0, 1, 0, 2); // Add the cheese details content grid.Children.Add (detailsView, 1, 4, 0, 1); grid.Children.Add ( ratingView , 1, 1); var stack = new StackLayout () { Children = {grid}, Padding = new Thickness (0, 5, 0, 5) }; this.View = stack; }
void InitializeDisplay() { Title = "Add Rating"; var cheeseNameLabel = new Label () { Text = "Cheese Name:" }; var cheeseNameText = new Entry () { BackgroundColor = CheeseColors.WHITE }; cheeseNameText.SetBinding (Entry.TextProperty, "CheeseToAdd.CheeseName"); var dairyNameLabel = new Label () { Text = "Dairy Name:" }; var dairyNameText = new Entry () { BackgroundColor = CheeseColors.WHITE }; dairyNameText.SetBinding (Entry.TextProperty, "CheeseToAdd.DairyName"); var ratingLabel = new Label () { Text = "Rating:" }; var ratingView = new RatingView (true); ratingView.SetBinding (RatingView.WedgeRatingProperty, "CheeseToAdd.WedgeRating"); var notesLabel = new Label () { Text = "Notes:" }; var notesText = new Entry () { BackgroundColor = CheeseColors.WHITE, VerticalOptions = LayoutOptions.Start }; notesText.SetBinding (Entry.TextProperty, "CheeseToAdd.Notes"); var addButton = new Button () { Text = "Add", Command = _viewModel.AddCheeseCommand, BackgroundColor = CheeseColors.RED, TextColor = Color.White, FontAttributes = FontAttributes.Bold, FontSize = 18, BorderRadius = 0 }; var stack = new StackLayout () { Children = { cheeseNameLabel, cheeseNameText, dairyNameLabel, dairyNameText, ratingLabel, ratingView, notesLabel, notesText, addButton } }; var scroll = new ScrollView (); scroll.Content = stack; Content = scroll; }
void InitializeDisplay() { Title = "Add Rating"; var cheeseNameLabel = new Label() { Text = "Cheese Name:" }; var cheeseNameText = new Entry() { BackgroundColor = CheeseColors.WHITE }; cheeseNameText.SetBinding(Entry.TextProperty, "CheeseToAdd.CheeseName"); var dairyNameLabel = new Label() { Text = "Dairy Name:" }; var dairyNameText = new Entry() { BackgroundColor = CheeseColors.WHITE }; dairyNameText.SetBinding(Entry.TextProperty, "CheeseToAdd.DairyName"); var ratingLabel = new Label() { Text = "Rating:" }; var ratingView = new RatingView(true); ratingView.SetBinding(RatingView.WedgeRatingProperty, "CheeseToAdd.WedgeRating"); var notesLabel = new Label() { Text = "Notes:" }; var notesText = new Entry() { BackgroundColor = CheeseColors.WHITE, VerticalOptions = LayoutOptions.Start }; notesText.SetBinding(Entry.TextProperty, "CheeseToAdd.Notes"); var addButton = new Button() { Text = "Add", Command = _viewModel.AddCheeseCommand, BackgroundColor = CheeseColors.RED, TextColor = Color.White, FontAttributes = FontAttributes.Bold, FontSize = 18, BorderRadius = 0 }; var stack = new StackLayout() { Children = { cheeseNameLabel, cheeseNameText, dairyNameLabel, dairyNameText, ratingLabel, ratingView, notesLabel, notesText, addButton } }; var scroll = new ScrollView(); scroll.Content = stack; Content = scroll; }
public AddRatingView(Cheese cheese) { _viewModel = new AddRatingViewModel(cheese, this); BindingContext = _viewModel; var cheeseName = new Label(); cheeseName.Text = string.Format("The cheese name is {0}", _viewModel.RatingToAdd.CheeseName); var dairyName = new Label() { Text = "Dairy Name" }; dairyName.Text = string.Format("The dairy name is {0}", _viewModel.RatingToAdd.DairyName); var ratingLabel = new Label() { Text = "Rating:" }; var notesLabel = new Label() { Text = "Notes:" }; var ratingView = new RatingView(true); ratingView.SetBinding(RatingView.WedgeRatingProperty, "RatingToAdd.WedgeRating"); var notesEntry = new Entry() { }; notesEntry.SetBinding(Entry.TextProperty, "RatingToAdd.Notes"); var entryGrid = new Grid() { ColumnSpacing = 0, RowSpacing = 2, VerticalOptions = LayoutOptions.Start }; entryGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); entryGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); entryGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); entryGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); entryGrid.Children.Add(ratingLabel, 0, 0); entryGrid.Children.Add(ratingView, 1, 0); entryGrid.Children.Add(notesLabel, 0, 1); entryGrid.Children.Add(notesEntry, 1, 1); var saveButton = new Button() { Text = "Save", FontAttributes = FontAttributes.Bold, BackgroundColor = CheeseColors.RED, TextColor = Color.White, FontSize = 18, BorderRadius = 0 }; saveButton.Command = _viewModel.AddRatingCommand; var cancelButton = new Button() { Text = "Cancel", FontAttributes = FontAttributes.Bold, BackgroundColor = CheeseColors.GRAY, TextColor = Color.White, FontSize = 18, BorderRadius = 0 }; var grid = new Grid() { RowDefinitions = { new RowDefinition { Height = new GridLength(40, GridUnitType.Star) } }, ColumnDefinitions = { new ColumnDefinition() { Width = new GridLength(.5, GridUnitType.Star) }, new ColumnDefinition() { Width = new GridLength(.5, GridUnitType.Star) } }, Padding = new Thickness(0, 0, 0, 0), RowSpacing = 0, ColumnSpacing = 0 }; grid.Children.Add(saveButton, 0, 0); grid.Children.Add(cancelButton, 1, 0); cancelButton.Clicked += async(sender, e) => { await Navigation.PopAsync(true); }; var cameraImage = new FileImageSource(); cameraImage.File = "Camera.png"; var cameraButton = new Button() { Image = cameraImage, Text = "Take Photo" }; cameraButton.Clicked += async(sender, e) => { var cv = new CameraView(); await Navigation.PushModalAsync(cv); }; var scroll = new ScrollView(); scroll.Content = new StackLayout { Children = { cheeseName, dairyName, entryGrid, cameraButton, grid } }; var headerImage = new Image { Source = "Rectangle1.png", Aspect = Aspect.AspectFill }; Content = new StackLayout() { Children = { headerImage, scroll } }; }