Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.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# 为什么在这个xaml代码中图像没有垂直拉伸?_C#_Wpf_Xaml - Fatal编程技术网

C# 为什么在这个xaml代码中图像没有垂直拉伸?

C# 为什么在这个xaml代码中图像没有垂直拉伸?,c#,wpf,xaml,C#,Wpf,Xaml,我有这个xaml代码: <Grid > <Grid.ColumnDefinitions> <ColumnDefinition Width="640*" /> <ColumnDefinition Width="14"/> <ColumnDefinition Width="350*"/> <

我有这个xaml代码:

 <Grid >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="640*" />
                <ColumnDefinition Width="14"/>
                <ColumnDefinition Width="350*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="30"/>
                <RowDefinition Height="40"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

<ListView Grid.Column="0" Grid.Row="2"  HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"                     ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Visible" SelectionMode="Single" >
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Border x:Name="border" BorderBrush="Black" BorderThickness="1" Margin="0,1,0,0">
                            <Grid  Background="Transparent" VerticalAlignment="Center" HorizontalAlignment="Stretch">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" MinWidth="300"/>
                                    <ColumnDefinition Width="4"/>
                                    <ColumnDefinition Width="*" MinWidth="300"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" MinHeight="150"/>
                                    <RowDefinition Height="4"/>
                                    <RowDefinition Height="20" />
                                </Grid.RowDefinitions>
                                <Image Grid.Column="0" Grid.Row="0"  Stretch="UniformToFill" StretchDirection="Both">
                                    <Image.Source>                                        
                                    </Image.Source>
                                </Image>
                                <TextBlock Grid.Column="0" Grid.Row="2"   FontWeight="Black" TextAlignment="Center" >
                                    <TextBlock.Text >
                                    </TextBlock.Text>
                                </TextBlock>
                                <Image Grid.Column="2" Grid.Row="0"   Stretch="UniformToFill" StretchDirection="Both" >
                                    <Image.Source>
                                    </Image.Source>
                                </Image>
                                <TextBlock Grid.Column="2" Grid.Row="2" FontWeight="Black" TextAlignment="Center" >
                                    <TextBlock.Text >
                                    </TextBlock.Text>
                                </TextBlock>

                            </Grid>
                        </Border>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
 </Grid>

当我调整这个xaml所在的窗口的大小时,我可以看到图像被调整大小以填充宽度,但它们没有调整大小以填充高度。如果图像对于高度来说太大,则显示图像的顶部,而不是底部

如何更改此xaml,使其在宽度或高度更改时,列表视图中的图像大小也会更改?

请参阅文档
UniformToFill保留了方面
我想你需要填补


谢谢。填充的问题是没有保留纵横比(正如您所提到的),我想要的是,当我更改窗口的宽度时,一旦图像的宽度改变,其高度(listview中项目的高度)就会改变以反映图像的实际高度。那么,您尝试过填充吗?它怎么办?你知道ListView在一个固定宽度的列中吗?当ListView的大小增加时,图像会增加,但是当我减小ListView的大小时,图像的大小不会变大。