Thursday, December 31, 2009

How To Add Border To Image Within DataGrid Column in Silverlight


<data:DataGridTemplateColumn Header="Image">
                        <data:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Border BorderBrush="Black" Width="101"  BorderThickness="1,1,1,1" Height="13" >
                                    <Image Width="25" Height="11" Source="http://localhost/SLR/images/pers_org.png" Stretch="UniformToFill" HorizontalAlignment="Left"  Canvas.Top="0" Canvas.Left="0" >
                                    </Image>
                                </Border>
                            </DataTemplate>
                        </data:DataGridTemplateColumn.CellTemplate>
                    </data:DataGridTemplateColumn>

//Bind the Following code within datagrid LoadingRow Event

Border border = (Border)dgName.Columns[4].GetCellContent(e.Row);// value 4 is the Possible of the Cell in the datagrid
Image image = (Image)border.Child;
//RelMang tmpRm = (RelMang)e.Row.DataContext;
//image.Width = Convert.ToDouble(tmpRm.mx_Rel_Prcntg.ToString());
image.Width = Convert.ToDouble(20); // Dynamically Setting Width of the Image Which in Datagrid Cell



No comments:

Creative Commons License
Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.