I have a C# class like this used in my application. It is a grid with four buttons.
If I view two buttons the output is:
If I view three buttons the output is:
Note that as the btn2 and btn3 are identical I can find now reason why two works and three does not:
public class PracticeButtons : Grid
{
public PracticeButtons()
{
this.Padding = new Thickness(20, 0, 20, 0);
var btn1 = new CardButtonTemplate()
{
ButtonBackgroundColor = (Color)Application.Current.Resources["IosRed"],
HorizontalOptions = LayoutOptions.CenterAndExpand,
VerticalOptions = LayoutOptions.Center
};
btn1.SetBinding(CardButtonTemplate.TapCommandProperty, new Binding("ABtnCmd"));
btn1.SetBinding(CardButtonTemplate.TextTopProperty, new Binding("ABtnTitleLabelTop"));
btn1.SetBinding(CardButtonTemplate.TextBtmProperty, new Binding("ABtnTitleLabelBtm"));
var btn2 = new CardButtonTemplate()
{
ButtonBackgroundColor = (Color)Application.Current.Resources["IosOrange"],
HorizontalOptions = LayoutOptions.CenterAndExpand,
VerticalOptions = LayoutOptions.Center
};
btn2.SetBinding(CardButtonTemplate.TapCommandProperty, new Binding("BBtnCmd"));
btn2.SetBinding(CardButtonTemplate.TextTopProperty, new Binding("BBtnTitleLabelTop"));
btn2.SetBinding(CardButtonTemplate.TextBtmProperty, new Binding("BBtnTitleLabelBtm"));
var btn3 = new CardButtonTemplate()
{
ButtonBackgroundColor = (Color)Application.Current.Resources["IosOrange"],
HorizontalOptions = LayoutOptions.CenterAndExpand,
VerticalOptions = LayoutOptions.Center
};
btn3.SetBinding(CardButtonTemplate.TapCommandProperty, new Binding("BBtnCmd", source: this));
btn3.SetBinding(CardButtonTemplate.TextTopProperty, new Binding("BBtnTitleLabelTop", source: this));
btn3.SetBinding(CardButtonTemplate.TextBtmProperty, new Binding("BBtnTitleLabelBtm", source: this));
this.Children.Add(btn1, 0, 0);
this.Children.Add(btn2, 1, 0);
this.Children.Add(btn3, 2, 0); // commented when viewing 2 buttons
}
}

