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 grid.like this




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;  

Wednesday, November 28, 2012

Silverlight multiline textbox

For multiline text box you have to use just 2 property for text box AcceptsReturn="True" TextWrapping="Wrap". consider the datagrid.





the xaml code for the

  <sdk:DataGridTemplateColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False" Width="Auto" Header="Remarks" >  
             <sdk:DataGridTemplateColumn.CellTemplate>  
               <DataTemplate>  
                 <TextBox AcceptsReturn="True" TextWrapping="Wrap"></TextBox>  
               </DataTemplate>  
             </sdk:DataGridTemplateColumn.CellTemplate>  
           </sdk:DataGridTemplateColumn>  

thank you.

Tuesday, November 20, 2012

Silverlight application Life cycle



Quick review how a silverlight application work in browser

1. The user requests the HTML entry page in the browser.

2. The browser loads the Silverlight plug-in. It then downloads the XAP file that contains your application.

3. The Silverlight plug-in reads the AppManifest.xml file from the XAP to find out what assemblies your application uses. It creates the Silverlight runtime environment and then loads your application assembly (along with any dependent assemblies).

4. The Silverlight plug-in creates an instance of your custom application class (which is defined in the App.xaml and App.xaml.cs files).

5. The default constructor of the application class raises the Startup event.

6. Your application handles the Startup event and creates the root visual object for your application.

Monday, November 19, 2012

Silverlight 5 Datagrid xaml binding

Let see how to look our datagrid



it is very simple, as a data source  i just use a _listObj of my class. and bind the grid column with my class attribute.


  <sdk:DataGrid SelectedItem="{Binding Path=SelectedStudent,Mode=TwoWay}" ItemsSource="{Binding Path= StudentList,Source={StaticResource OutSouceItemList}, Mode=TwoWay}" CanUserResizeColumns="False" AutoGenerateColumns="False" ColumnWidth="*" Name="dgStudentList" VerticalScrollBarVisibility="Visible" MaxHeight="Infinity" >  
           <sdk:DataGrid.Columns>  
             <sdk:DataGridTextColumn Visibility="Collapsed" Binding="{Binding StudentId}" CanUserReorder="False" CanUserResize="False" CanUserSort="False" Width="*" />  
             <sdk:DataGridTextColumn Header="First name" Binding="{Binding FirstName}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="*" />  
             <sdk:DataGridTextColumn Header="Last Name" Binding="{Binding LastName}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="*" />  
             <sdk:DataGridTextColumn Header="Father name" Binding="{Binding FatherName}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="*" />  
             <sdk:DataGridTextColumn Header="Mother Name" Binding="{Binding MotherName}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="*" />  
             <sdk:DataGridTextColumn Header="Country" Binding="{Binding Country}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="*" />  
             <sdk:DataGridTemplateColumn x:Name="Edit" Width="*" Header="Edit" CanUserResize="False" CanUserReorder="False" CanUserSort="False">  
               <sdk:DataGridTemplateColumn.CellTemplate>  
                 <DataTemplate>  
                   <StackPanel>  
                     <HyperlinkButton Content=" " Command="{Binding SaveCommand}">  
                       <HyperlinkButton.Background>  
                         <ImageBrush ImageSource="/GoStudyBD_SLV;component/Assets/Images/edit_icon.png"></ImageBrush>  
                       </HyperlinkButton.Background>  
                     </HyperlinkButton>  
                   </StackPanel>  
                 </DataTemplate>  
               </sdk:DataGridTemplateColumn.CellTemplate>  
             </sdk:DataGridTemplateColumn>  
             <sdk:DataGridTemplateColumn x:Name="Delete" Width="*" Header="Delete" CanUserResize="False" CanUserReorder="False" CanUserSort="False">  
               <sdk:DataGridTemplateColumn.CellTemplate>  
                 <DataTemplate>  
                   <StackPanel>  
                     <HyperlinkButton Content=" " Command="{Binding Source={StaticResource OutSouceItemList}, Path=DeleteCommand}" CommandParameter="{Binding}" IsEnabled="{Binding Path=IsEnabled,Mode=TwoWay}" >  
                       <HyperlinkButton.Background>  
                         <ImageBrush ImageSource="/GoStudyBD_SLV;component/Assets/Images/delete_icon.png"></ImageBrush>  
                       </HyperlinkButton.Background>  
                     </HyperlinkButton>  
                   </StackPanel>  
                 </DataTemplate>  
               </sdk:DataGridTemplateColumn.CellTemplate>  
             </sdk:DataGridTemplateColumn>  
           </sdk:DataGrid.Columns>  
         </sdk:DataGrid>  


here i use MVVM you can also download the code.

https://skydrive.live.com/?cid=dbc6b335a854cc0e#cid=DBC6B335A854CC0E&id=DBC6B335A854CC0E%212389

Thursday, November 15, 2012

Silverlight 5 Development environment



Install the software step by step.

1. Install VS-2010

2. Install SQL Server 2008 R2 or other

3. Install VS Service Pack 1

Http://download.microsoft.com/download/E/B/A/EBA0A152-F426-47E6-9E3F-EFB686E3CA20/VS2010SP1dvd1.iso

4. Install Silverlight Toolkit

https://skydrive.live.com/?cid=dbc6b335a854cc0e#cid=DBC6B335A854CC0E&id=DBC6B335A854CC0E%212387

5. install Prism4.1_Source

http://www.microsoft.com/en-us/download/details.aspx?id=28950

6. Install Blend_UltimateTrial_en(silverlight-5)

http://www.microsoft.com/en-us/download/details.aspx?id=9503

Now your PC is ready for Silverlight 5 development Environment.


SQL Get all Index create script from Database

To get all script from database as a create new index into another database you can use the following --Get all Index Script SELECT...