Normally our image can be different size when we upload the. if we want to fixed that all image size will be fixed in Silver light 5 Data grid.like this
XAML Binding for image:
on datagrid onloading event. set the image column with your class image attribute. here it is ColorImageFile
you also have to use this dll
XAML Binding for image:
<sdk:DataGridTemplateColumn Header="Color image" Width="6*" IsReadOnly="True" >
<sdk:DataGridTemplateColumn.CellTemplate >
<DataTemplate>
<Image Source="{Binding Path=ColorImageFile}" Stretch="Fill" Width="100" Height="60" Visibility="Visible"/>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
on datagrid onloading event. set the image column with your class image attribute. here it is ColorImageFile
private void DgReceiveBuyerComment_OnLoadingRow(object sender, DataGridRowEventArgs e)
{
try
{
BO.LAB_LDCommentReceipt labLdCommentObj = e.Row.DataContext as BO.LAB_LDCommentReceipt;
if (labLdCommentObj != null)
{
FrameworkElement ele = dgReceiveBuyerComment.Columns[4].GetCellContent(e.Row);
(ele as Image).Source =
new BitmapImage(new Uri(GlobalVar.ImagePath + labLdCommentObj.ColorImageFile,
UriKind.RelativeOrAbsolute));
}
}
catch (Exception ex)
{
throw ex;
}
}
you also have to use this dll
using System.Windows.Controls;
using System.Windows.Media.Imaging;
Comments
Post a Comment