Tôi đã có một danh sách WPF ListView/GridView spec'd trong XAML. Cột đầu tiên sử dụng một CellTemplate để xác định các biểu tượng và những người khác sử dụng DisplayMemberBinding để tự cư trú. Cột biểu tượng rộng 20, các biểu tượng 16 nhưng chúng bị cắt bớt theo lề/đệm/thứ gì đó. Tôi không thể tìm ra nơi nó được đặt.Vị trí lề/đệm được đặt trên GridView ListView của wpf ở đâu?
Đây là yếu tố cần thiết (tôi đã xóa một số cột vì họ giống nhau):
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="FontWeight" Value="Normal" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="FontWeight" Value="Bold" />
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
<ListView.Resources>
<DataTemplate x:Key="image">
<Image Width="16" Height="16" Margin="0,0,0,0"
HorizontalAlignment="Center"
Source="{Binding Path=ObjectType,
Converter={StaticResource imageConverter} }" />
</DataTemplate>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn Width="20"
CellTemplate="{StaticResource image}"/>
<GridViewColumn Width="120" Header="Name"
DisplayMemberBinding="{Binding Path=Name}"/>
</GridView>
</ListView.View>
ImageConverter chỉ quay một ObjectType thành một hình ảnh để từng loại mặt hàng có biểu tượng riêng.
Đẹp nhất, cảm ơn. – serialhobbyist