Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 设置ListView100%屏幕宽度(UWP)_C#_Xaml_Uwp - Fatal编程技术网

C# 设置ListView100%屏幕宽度(UWP)

C# 设置ListView100%屏幕宽度(UWP),c#,xaml,uwp,C#,Xaml,Uwp,我的UWP应用程序中有ListView,希望它设置100%的显示宽度 这是我在xaml文件中的代码 <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:/

我的UWP应用程序中有ListView,希望它设置100%的显示宽度

这是我在xaml文件中的代码

<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>

我试着这样做
Width=“100%”

但它不起作用

我怎样才能做到


  • 不要设置ListView的宽度
  • 设置或不设置水平对齐=“拉伸”
  • 这是你修改过的代码

    <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>
    
    
    

  • 不要设置ListView的宽度
  • 设置或不设置水平对齐=“拉伸”
  • 这是你修改过的代码

    <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>
    
    
    
    如果不设置ListView的宽度,则它将占用100%的屏幕。如果不设置ListView的宽度,则它将占用100%的屏幕。如果不设置ListView的宽度,则它将占用100%的屏幕,不需要100%@vijaynirmal将您的
    列表视图
    水平对齐
    更改为
    拉伸
    。可能重复