How can I make content of each ListView
item expands to 100% width when using a DataTemplate
?
I have tried HorizontalContentAlignment="Stretch"
in the ListView
and HorizontalAlignment="Stretch"
in the DataTemplate
, but nothing seems to work, content is still aligned to the left.
I have something like this:
<ListView x:Name="questionsView" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" HorizontalContentAlignment="Stretch">
<ListView.ItemTemplate>
<DataTemplate>
<Border Background="BlueViolet" HorizontalAlignment="Stretch">
<Grid HorizontalAlignment="Stretch">
<TextBlock Text="{Binding}" />
<TextBlock HorizontalAlignment="Right">16 minutes ago</TextBlock>
</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
I guess there is one more layer between the ListView
and the ItemTemplate
.
question from:
https://stackoverflow.com/questions/18626696/listview-itemtemplate-100-width 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…