A
A
Alexander Kosheverov2014-06-16 21:44:42
WPF
Alexander Kosheverov, 2014-06-16 21:44:42

WPF Datagrid how to bind multiple fields into one column?

Let's say my class has fields Par1, Par2, Par3.
I need a table with 2 columns, the first will be "Par1", the second will be "Par2 (Par3)"
If the first is implemented simply:

<DataGridTextColumn Binding="{Binding Par1}"  Header="{x:Static res:Resources.Header1}" Width="*" SortMemberPath="Par1"/>

then I don't know how to do the second one. You can, of course, use the DataGridTemplateColumn, but I have no idea how to fasten 2 Bindings to one floor at the same time.
Please advise. Either I give crooked requests to Google, or it does not give anything on the road.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Samoilov, 2014-06-17
@Iworb

<DataGridTemplateColumn Header="{x:Static res:Resources.Header2}" >
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Par2}"></TextBlock>
                <TextBlock Text="{Binding Par3}"></TextBlock>
            </StackPanel>
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question