一件事需要帮助。我有DataGrid
,将它绑定到这个类:
class Book
{
public string Title { get; set; }
public string Author { get; set; }
public string Tags { get; set; }
public string Year { get; set; }
public string Description { get; set; }
public string Path { get; set; }
public int Rating { get; set; }
public Statistics Stats { get; set; }
}
这是 XAML:
<DataGrid AutoGenerateColumns="False" EnableRowVirtualization="True" ItemsSource="{Binding}" Margin="56,49,12,12" Name="booksDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" ColumnWidth="*" MinWidth="400" MinHeight="250">
<DataGrid.Columns>
<DataGridTextColumn x:Name="titleColumn" Binding="{Binding Path=Title}" Header="Title" Width="2*" />
<DataGridTextColumn x:Name="authorColumn" Binding="{Binding Path=Author}" Header="Author" Width="*" />
<DataGridTextColumn x:Name="tagsColumn" Binding="{Binding Path=Tags}" Header="Tags" Width="*" />
<DataGridTextColumn x:Name="yearColumn" Binding="{Binding Path=Year}" Header="Year" Width="*" />
<DataGridTextColumn x:Name="ratingColumn" Binding="{Binding Path=Rating}" Header="Rating" Width="*" />
</DataGrid.Columns>
</DataGrid>
但我想显示的评级不是数字,而是五颗星的图像。如何将 int 值转换为带有图像的面板之类的东西?