我有一个视图,它是一个可折叠的列表,我希望能够按下一个按钮,上面写着添加另一个,然后它在当前视图下方添加另一个视图。这可以在 Xamarin Forms 中完成吗?
所以每次按下一个按钮时,添加另一个按钮:
<local:TimeSheetAccordion HeaderText="Customer #1" BackgroundColor="#FAFAFA" Padding="20, 20, 20, 20" />
页面代码:
<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 代码:
private void AddAnotherButton_Clicked(object sender, EventArgs e)
{
mainTimeLayout.Children.Add(new TimeSheetAccordion() {
HeaderText = "Customer #1",
BackgroundColor = Color.FromHex("#FAFAFA")
});
}
有没有办法可以设置它以便 HeaderText 递增?
狐的传说
相关分类