Reputation: 10499
I have a ListView
and I want to add some children. I want that these ListViewItems (for example Border
instances) have a Height of 25, and a Width equal to that of the ListView, even when I resize the ListView.
I try the following code to add 10 elements:
for (int i = 0; i < 10; i++)
{
ListPsw.Items.Add(new Border
{
BorderThickness = new Thickness(2),
BorderBrush = Brushes.Black,
Margin = new Thickness(5),
Height = 25
});
}
and this is the result:
But I want something like this:
How can I do?
Upvotes: 2
Views: 330
Reputation: 19296
You must set HorizontalContentAlignment
property to Stretch
.
<ListView Name="ListPsw" HorizontalContentAlignment="Stretch" />
Upvotes: 1