A. WPF中利用ListView.View中的GridView怎麼顯示圖片
我覺得會不會是你圖片Path問題,還是啥問題,我給你看下我寫的Demo
前台:
<Grid x:Name="bootGrid">
<ListView x:Name="listview">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn x:Name="gvc">
<GridViewColumn.Header>
<TextBlock>圖片列Title</TextBlock>
</GridViewColumn.Header>
<GridViewColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding ImgPath}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
</Grid>
後台:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
listview.ItemsSource = new List<TestDemo>()
{
new TestDemo(){ ImgPath = "\\Images\\shafa.jpg"}
};
}
}
public class TestDemo
{
public string ImgPath { get; set; }
}