我有一个带有边框的表单,其中包含一个列表视图,在我的 c# 代码中,边框的高度根据一个值而变化。现在边框高度变化没有问题但是我如何更新列表视图以与边框具有相同的高度?这是我的xml:
<DataTemplate x:Key="PackageTemplate">
<Border x:Name="PackageBorder" BorderBrush="Black" BorderThickness="2" Margin="10" Padding="0" Width="100" >
<Border.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Status}" Value="1">
<Setter Property="Border.Background" Value="#FF999696"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=Status}" Value="0">
<Setter Property="Border.Background" Value="#FFE4E4E4"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=Layout}" Value="0">
<Setter Property="Border.Height" Value="100"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=Layout}" Value="1">
<Setter Property="Border.Height" Value="200"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="70"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ListView Grid.Row="0" Grid.Column="0" Background="{x:Null}" x:Name="List" ItemsSource="{Binding Path=Collection}" ItemTemplate="{DynamicResource ChipTemplate}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" BorderThickness="0" BorderBrush="{x:Null}" Foreground="Black" VerticalAlignment="Top" Width="90" >
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" VerticalAlignment="Center" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
<Label Grid.Row="1" Grid.Column="0" Content="{Binding Path=Location}" FontSize="15" FontFamily="Arial" Foreground="Black" Background="{x:Null}" VerticalAlignment="Bottom" HorizontalAlignment="Left"></Label>
</Grid>
</Border>
</DataTemplate>