我有这行代码在框架中添加listview:
frame.Content = containerListView;
但是,我在stacklayout中也有一个按钮,我也希望将其包含在框架中。
我试过这个但没有运气:
frame.Content = containerListView && buttonStackLayout;
frame.Content = containerListView , buttonStackLayout;
这与其他堆栈帖子的情况不同,因为另一个帖子将2个stacklayout添加到viewcell。我需要将listview和stacklayout添加到帧内容中。
答案 0 :(得分:1)
首先,您需要创建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;
}