Hi I have a view which is a collapsible list and I want to be able to press a button which says add another then it adds another view underneath the current one. is this possible to do in Xamarin Forms?
so every time a button is pressed add another one of these:
<local:TimeSheetAccordion HeaderText="Customer #1" BackgroundColor="#FAFAFA" Padding="20, 20, 20, 20" />
page code:
<ScrollView>
<StackLayout Padding="20, 20, 20, 20">
<local:TimeSheetAccordion HeaderText="Customer #1" BackgroundColor="#FAFAFA" Padding="20, 20, 20, 20" />
<local:TimeSheetAccordion HeaderText="Customer #2" BackgroundColor="#FAFAFA" Padding="20, 20, 20, 20" />
<StackLayout Margin="0, 30, 0, 0" Orientation="Horizontal" HorizontalOptions="End">
<Button Text="Reset" BorderRadius="6" />
<Button Text="Submit Time Sheet" BackgroundColor="Blue" TextColor="White" BorderRadius="6" />
</StackLayout>
</StackLayout>
</ScrollView>
page.xaml.cs Code:
private void AddAnotherButton_Clicked(object sender, EventArgs e)
{
mainTimeLayout.Children.Add(new TimeSheetAccordion() {
HeaderText = "Customer #1",
BackgroundColor = Color.FromHex("#FAFAFA")
});
}
is there a way I can set it so the HeaderText is incremented?