Ershad
Ershad

Reputation: 41

In WPF can i display empty rows in listview without binding to anything?

Is it possible to show specified number of rows in the listview. This is because my whole listview area looks empty, but after values are binded it is ok. So is it possible to show rows before binding.

Thanks,

Upvotes: 3

Views: 1285

Answers (2)

Simon P Stevens
Simon P Stevens

Reputation: 27499

In the XAML you could do something like this:

<ListView name="myListView">
    <ListViewItem>test1</ListViewItem>
    <ListViewItem>test2</ListViewItem>
</ListView>

That would populate some test items in the list view to be displayed. You would need to clear the listview's items collection before you bound to it though or you'll get an exception:

myListView.Items.Clear()

Upvotes: 1

Peter
Peter

Reputation: 14108

See if you can use the AddChild method or just use myListView.Items.Add(new ListViewItem()).

Just an educated guess, I can't try this out right now.

Upvotes: 0

Related Questions