Last active
August 30, 2023 20:41
-
-
Save MitchMilam/532003de91028f158a66 to your computer and use it in GitHub Desktop.
Demonstrates how to put to views into a single cell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NumberCellPage : ContentPage | |
{ | |
public NumberCellPage() | |
{ | |
var grid = new Grid | |
{ | |
RowSpacing = 0, | |
VerticalOptions = LayoutOptions.FillAndExpand, | |
HorizontalOptions = LayoutOptions.FillAndExpand | |
}; | |
grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(150) }); | |
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(150) }); | |
var image = new Image | |
{ | |
Aspect = Aspect.AspectFill, | |
Source = "circle.jpg", | |
VerticalOptions = LayoutOptions.CenterAndExpand, | |
HorizontalOptions = LayoutOptions.CenterAndExpand | |
}; | |
var labelTitle = new Label | |
{ | |
Font = Font.OfSize("Helvetica Light", 50), | |
TextColor = Color.Black, | |
Text = "1", | |
VerticalOptions = LayoutOptions.CenterAndExpand, | |
HorizontalOptions = LayoutOptions.CenterAndExpand | |
}; | |
var contentTitle = new ContentView | |
{ | |
Padding = new Thickness(0, 2, 0, 0), | |
VerticalOptions = LayoutOptions.Fill, | |
HorizontalOptions = LayoutOptions.Fill, | |
Content = labelTitle | |
}; | |
grid.Children.Add(image); | |
Grid.SetRow(image, 0); | |
Grid.SetColumn(image, 0); | |
grid.Children.Add(contentTitle); | |
Grid.SetRow(contentTitle, 0); | |
Grid.SetColumn(contentTitle, 0); | |
var stack = new StackLayout | |
{ | |
VerticalOptions = LayoutOptions.Center, | |
HorizontalOptions = LayoutOptions.CenterAndExpand, | |
Orientation = StackOrientation.Vertical, | |
Children = { grid }, | |
}; | |
// Once you have Binding connected, uncomment these. | |
//image.SetBinding(Image.SourceProperty, new Binding("Image")); | |
//labelTitle.SetBinding(Label.TextProperty, new Binding("Title")); | |
Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); | |
Content = stack; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment