コード例 #1
0
		public EmployeeDetailPage (Employee employee)
		{
			_employee = employee;

			#region Initialize some properties on the Page
			Padding = new Thickness (20);
			BindingContext = employee;
			#endregion

			#region Initialize the command that will be execute when the user clicks on the delete button.
			_deleteCommand = new Command (() => {
				App.Employees.Remove (_employee);
				Navigation.PopAsync ();
			});
			#endregion

			#region Create the controls for the Page.
			Image employeeImage = new Image {
				HeightRequest = 200,
				Source = ImageSource.FromFile (_employee.ImageUri),
			};

			// Put the two buttons inside a grid
			Grid buttonsLayout = new Grid {
				ColumnDefinitions = {
					new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (2, GridUnitType.Star) },
				},
				Children = {
					{ CreateDeleteButton (), 0, 0 },
					{ CreateSaveButton (), 1, 0 }
				}
			};

			// Create a grid to hold the Labels & Entry controls.
			Grid inputGrid = new Grid {
				ColumnDefinitions = {
					new ColumnDefinition { Width = GridLength.Auto },
					new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
				},
				Children = { {
						new Label {
							Text = "First Name:",
							FontFamily = Fonts.SmallTitle.FontFamily,
							FontSize = Fonts.SmallTitle.FontSize,
							TextColor = Colours.SubTitle
						},
						0,
						0
					}, {
						new Label {
							Text = "Last Name:",
							FontFamily = Fonts.SmallTitle.FontFamily,
							FontSize = Fonts.SmallTitle.FontSize,
							TextColor = Colours.SubTitle
						},
						0,
						1
					}, {
						new Label {
							Text = "Twitter: ",
							HorizontalTextAlignment = TextAlignment.End,
							FontFamily = Fonts.SmallTitle.FontFamily,
							FontSize = Fonts.SmallTitle.FontSize,
							TextColor = Colours.SubTitle
						},
						0,
						2
					},
					{ CreateEntryFor ("FirstName"), 1, 0 },
					{ CreateEntryFor ("LastName"), 1, 1 },
					{ CreateEntryFor ("Twitter"), 1, 2 }
				}
			};
			#endregion

			// Add the controls to a StackLayout 
			Content = new StackLayout {
				Children = {
					employeeImage,
					inputGrid,
					buttonsLayout
				}
			};
		}
コード例 #2
0
 public EmployeeDetailPage(Employee employee)
 {
     InitializeComponent();
     this.BindingContext = employee;
 }