Thursday, November 29, 2012

Silverkight 5 datagrid image size

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 this

XAML Binding for image:

  <sdk:DataGridTemplateColumn Header="Color image" Width="6*" IsReadOnly="True" >  
             <sdk:DataGridTemplateColumn.CellTemplate >   
                 <Image Source="{Binding Path=ColorImageFile}" Stretch="Fill" Width="100" Height="60" Visibility="Visible"/>  

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)  
         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,  
       catch (Exception ex)  
         throw ex;  

you also have to use this dll

 using System.Windows.Controls;  
 using System.Windows.Media.Imaging;  

vfpoledeb.1 provider is not registered on the local machine

Have u Install VFP Ole DB Provider in your System ? If No then Please Install it from following link.