how to format the data inside the DataGridTemplateColumn in datagrid

Posted by prince23 on Stack Overflow See other posts from Stack Overflow or by prince23
Published on 2010-05-17T06:42:28Z Indexed on 2010/05/17 7:50 UTC
Read the original article Hit count: 260

Filed under:

hi,

this is my xaml code where i have 2 fields placed under one template column.

now i am getting the format the output like this so that i can specify the space betweeen these 2 columns

    Color

red        image1

green     image2

green     image2

white     image6

so that output looks good.

How can i define space between them so that it looks like the above one

right now thw output is like this

    color

    Redimage1

    greenimage2

    greenimage2

    whiteimage6
<sdk:DataGridTemplateColumn  Header="Color" Width="80">
    <sdk:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <StackPanel Loaded ="StackPanel_Loaded" Orientation="Horizontal" Background="Transparent">
                <TextBlock Text="{Binding Color}" TextWrapping="NoWrap" HorizontalAlignment="Center" Foreground="Blue"></TextBlock>
                <Image x:Name="imgTargetScore" Source ="{Binding ColorImage}" Width="20" Height="20" Stretch ="Fill"/>
            </StackPanel>
        </DataTemplate>
    </sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>

loking forward for an solution

thanks in advance

prince

© Stack Overflow or respective owner

Related posts about silverlight-4.0