Reputation: 329
I have this line of code to add the listview in the frame:
frame.Content = containerListView;
However, I also have a button inside a stacklayout that I also want to be included in the frame.
I tried this but no luck:
frame.Content = containerListView && buttonStackLayout;
frame.Content = containerListView , buttonStackLayout;
This is not the same scenario as the other stack post because the other post adds 2 stacklayouts to a viewcell. I need to add a listview and stacklayout to a frames content.
Upvotes: 1
Views: 1944
Reputation: 998
Firstly, you need to create your StackLayout
and Button
then add add them as the content of your
//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);
Edit
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;
}
Upvotes: 4