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

header in listview problem

$
0
0

Hi

I would like to have a header in listview only if there aren't item in a listview.
If i write something like

                    if(App.ListaSoggetti == null)
                        _listView.Header = new Label() {
                        Text="Nessun dato", 
                        XAlign = TextAlignment.Center,
                        FontSize = Library.GetFontNamedSize(NamedSize.Large, typeof(Label)),
                        HorizontalOptions = LayoutOptions.CenterAndExpand};
                    else
                        try{
                        _listView.Header = null;
                    }
                    catch(Exception ex){
                        DisplayAlert("Errore", ex.Message, "Ok");
                    }

If App.ListaSoggetti == null, I have "Nessun dato" in the header, but if I call again this code with App.ListaSoggetti != null, the

                        _listView.Header = null;

freeze the app.
If I write

                        _listView.Header = "";

instead of

                        _listView.Header = null;

it works but I see an empty header (I would like not to have an empty header, I would like to have no header)
How can I remove the header from the list?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>