tags:

views:

15

answers:

1

Hello. How can I store custom object in WPF DataGrid cell? For example, I want to store something like this: http://yfrog.com/0583557380j.

I have no ideas :(. Thanks.

A: 

Use a DataGridTemplateColumn:

<DataGrid ItemsSource="{Binding}" AutoGenerateColumns="False" >
    <DataGrid.Columns>
        <DataGridTemplateColumn Header="Custom Column">
            <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <!-- whatever you like in here -->
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridtemplateColumn>
    </DataGrid.Columns>
</DataGrid>

HTH,
Kent

Kent Boogaart
Thanks, that's all of I need :). Can you help me with another problem?How can I set dependence between font color and integer value? For example, for value "4" color is green, for value "-3" - red. *don't know*
Dmitriy
@Dmitriy: no problem. If you have another question, feel free to create a new topic for it rather than attempting to address it here.
Kent Boogaart