首先,你需要创造
StackLayout
和
Button
然后添加它们作为
//StackLayout
StackLayout buttonStack = new StackLayout()
{
Padding = new Thickness(0, 10),
HorizontalOptions = LayoutOptions.FillAndExpand,
BackgroundColor = "Gray" ,
};
//Button
Button btn = new Button() { Text = "Button", HorizontalOptions = LayoutOptions.Center};
btn.Clicked += btn_Clicked; //don't forget to create the btn_Clicked event/method
buttonStack.Children.Add(btn);
编辑
private ListView GetListView(int index)
{
ListView listView = new ListView();
listView.ItemsSource = //your list Source
Frame frame = new Frame();
frame.Margin = new Thickness(3);
frame.Content = listView;
return listView;
}