1、带有GridView的ListView样式
https://www.cnblogs.com/king10086/p/11905494.html
2、动态更改listview某一项的文字颜色
https://bbs.csdn.net/topics/390859580
https://docs.microsoft.com/zh-cn/previous-versions/ms750769(v=vs.100)?redirectedfrom=MSDN
<Style TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<DataTrigger Binding="{Binding LoginStat}" Value="登陆失败">
<Setter Property="Foreground" Value="Red" />
</DataTrigger>
</Style.Triggers>
</Style>
3、ListView插入图片
<ListView x:Name="TvBox" HorizontalAlignment="Stretch" VerticalAlignment="Top"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <UniformGrid Columns="5" HorizontalAlignment="Stretch"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ListView.ItemTemplate> <DataTemplate> <StackPanel Orientation="Vertical" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> <Image Source="{Binding ImageData}" HorizontalAlignment="Stretch" VerticalAlignment="Top" Stretch="UniformToFill" /> <TextBlock Text="{Binding Title}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" /> </StackPanel> </DataTemplate> </ListView.ItemTemplate> </ListView>
public partial class Window1 : Window { public Window1() { InitializeComponent(); this.TvBox.ItemsSource = new MovieData[] { new MovieData{Title="Movie 1", ImageData=LoadImage("image.jpg")}, new MovieData{Title="Movie 2", ImageData=LoadImage("image.jpg")}, new MovieData{Title="Movie 3", ImageData=LoadImage("image.jpg")}, new MovieData{Title="Movie 4", ImageData=LoadImage("image.jpg")}, new MovieData{Title="Movie 5", ImageData=LoadImage("image.jpg")}, new MovieData{Title="Movie 6", ImageData=LoadImage("image.jpg")} }; } // for this code image needs to be a project resource private BitmapImage LoadImage(string filename) { return new BitmapImage(new Uri("pack://application:,,,/" + filename)); } }