Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

When added something to a StackLayout, it adds itself to the middle.

$
0
0

I made a searchbar, which I'm adding to the stacklayout:

 var stack = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand
            };



var searchArticleBar = new SearchBar
        {
            Placeholder = "Enter text and hit search..",
        };


stack.Children.Add(searchArticleBar);


// Then I'm making a Listview, which I also will add to the StackLayout
var listView = new ListView();

// Initialization of items is removed for demonstration purposes
stack.Children.Add(listView);

Content = stack;

This piece of code shows the following on startup [attachment 2.png]. And when the list is loaded, the view shows the following [attachment 3.png].

Why isn't the SearchBar located at the top all the time?


Viewing all articles
Browse latest Browse all 58056

Trending Articles