Reputation: 121
I have ListView in my UWP app and want it to set 100% of width of display.
Here is my code in xaml file
<Page
x:Class="TestApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TestApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ListView x:Name="PostList" ItemsSource="{Binding PostsList}" HorizontalAlignment="Left" Height="720" VerticalAlignment="Top" Width="1280">
<ListView.ItemTemplate>
<DataTemplate>
<Grid x:Name="GridInf" Height="204" BorderBrush="#FFFBF8F8" BorderThickness="0,0,1,1">
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
I try to do like this Width="100%"
But it not works?
How I can make it?
Upvotes: 1
Views: 2408
Reputation: 5837
HorizontalAlignment="Stretch"
or don't set itHere is your modified code
<ListView x:Name="PostList" ItemsSource="{Binding PostsList}" HorizontalAlignment="Stretch" Height="720" VerticalAlignment="Top">
<ListView.ItemTemplate>
<DataTemplate>
<Grid x:Name="GridInf" Height="204" BorderBrush="#FFFBF8F8" BorderThickness="0,0,1,1">
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Upvotes: 6