Hello there, I have some issue in my program. I set FlexLayout.AlignItems = center but I want to have one button into layout at the right side. this is my code:
private void FillPage() { ListView SpotView = new ListView { ItemsSource = Spots, HeightRequest = 250, RowHeight = 50, Margin = new Thickness(0, 0, 10, 0), ItemTemplate = new DataTemplate(() => { Label Text = new Label { Text = "Parking spot number ", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center }; Label Number = new Label() { TextColor = Color.FromHex("#007AFF"), HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, FontAttributes = FontAttributes.Bold, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) }; Number.SetBinding(Label.TextProperty, "ParkingSpotNumber"); return new ViewCell { View = new StackLayout { VerticalOptions = LayoutOptions.Center, Margin = new Thickness(20, 0, 0, 0), Children = { new Grid(){ Children = { Text, Number } } } } }; }) }; Button RefreshButton = new Button() // this button here { Text = "Refresh", Margin = new Thickness(0, 0, 40, 0), Padding = new Thickness(20, 10, 20, 10), HeightRequest = 35, BackgroundColor = Color.FromHex("#D2E9FC"), }; RefreshButton.Clicked += async (sender, args) => await GetParkingInfo(); //FlexAlign.SetAlignSelf(RefreshButton, FlexAlignSelf.End); <---- BAD USSAGE // Build the page Content = new FlexLayout { Direction = FlexDirection.Column, AlignItems = FlexAlignItems.Center, JustifyContent = FlexJustify.SpaceEvenly, Children = { SpotView, RefreshButton } }; }
I find this: "FlexAlign.SetAlignSelf(RefreshButton, FlexAlignSelf.Center)"but I don't know how to use it.
thanks for your advice.
If you want to set an individual item's AlignItems
, you could try:
// Build the page FlexLayout.SetAlignSelf(RefreshButton, FlexAlignSelf.End); Content = new FlexLayout { Direction = FlexDirection.Column, AlignItems = FlexAlignItems.Center, JustifyContent = FlexJustify.SpaceEvenly, Children = { SpotView, RefreshButton } };
Answers
If you want to set an individual item's
AlignItems
, you could try:thank a lot
it works.