wpf中的datagrid中如何显示图片

2012-09-11 10:55

 

在datagrid中添加一个模板列,xaml内容如下:

<DataGridTemplateColumn Header="头像" Width="SizeToCells" IsReadOnly="True">

                                <DataGridTemplateColumn.CellTemplate>

                                    <DataTemplate>

                                        <Image Height="40"  Source="{Binding Path=PHOTO}"  />

                                    </DataTemplate>

                                </DataGridTemplateColumn.CellTemplate>

                            </DataGridTemplateColumn>


注意:其中的Source="{Binding Path=PHOTO}",就是这一句起到了作用,PHOTO就是数据表中的列名。

原文地址:https://www.cnblogs.com/swarb/p/9924367.html