这是我用来绑定包含架构图像的项目列表的一些 XAML 代码。我的图像显示正确,但未填充 ListViewItem 的宽度,尽管高度已正确填充。我的图像也是方形的,所以我知道这不会发生,因为图像没有明显的失真。
此外,我注意到 ListViewItem 有一个浅灰色的背景颜色,它应该是透明的,或者 null/none。
有人知道如何正确绑定吗?
<ListView x:Name="listView_Architecture" SelectionMode="Single" ScrollViewer.VerticalScrollBarVisibility="Disabled" VerticalContentAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Visible" HorizontalContentAlignment="Stretch" SelectionChanged="listView_Architecture_SelectionChanged">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsVisible}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding IsVisible}" Value="False">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
<DataTrigger Binding="{Binding IsSelected, Mode=TwoWay}" Value="True">
<Setter Property="IsSelected" Value="True" />
</DataTrigger>
<DataTrigger Binding="{Binding IsSelected, Mode=TwoWay}" Value="False">
<Setter Property="IsSelected" Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView AllowsColumnReorder="False">
<GridView.ColumnHeaderContainerStyle>
<Style TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Visibility" Value="Collapsed"/>
</Style>
</GridView.ColumnHeaderContainerStyle>
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<Image Stretch="Fill" Source="{Binding SetupImage, Converter={StaticResource ImageToSourceConverter}}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>