Hello,
Welcome to our Microsoft Q&A platform!
what am I doing wrong that my custom control is not being rendered correctly
This is because 'FooterButton' is type of StackLayout
which cannot display a text or an image directly. As Viorel-1 said, try adding child views to the layout to display the content.
how can I assign the property of FlexLayout.SelfAsign in c# code of a custom element that will be in a Flexlayout
To specify the asign value for a control in code, try using FlexLayout.SetAlignSelf
command. Here is the sample code, you could refer to it.
var footerButton = new FooterButton
{
Text = "Inquiry",
Transform = TextTransform.Uppercase,
TextColor = ColorPalette.Red,
Source = Utilities.GetGlyph(FontAwesome.FontAwesomeIcons.Envelope, Fonts.FontAwesomeRegular, ColorPalette.Red, 28)
}
FlexLayout.SetAlignSelf(footerButton, FlexAlignSelf.Center);
this.Body.Children.Add(FooterButton);
The related doc: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/flex-layout#the-alignself-property
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.