CareTaker22 CareTaker22 - 2 months ago 10
C# Question

Combining CheckBoxColumn and TextColumn into one column

Is it possible to combine a

DataGridTextColumn
and
DataGridCheckBoxColumn
into one column?

I have this class where I combine two columns values into one result:

public class ViewQuoteItemList
{
public string Supplier { get; set; }
public bool TrueFalse { get; set; }

public string CheckBoxColumn
{
get { return string.Format("{0} {1}", Supplier, TrueFalse); }
}
}


Then I bind one of the columns like this:

DataGridTextColumn columnFeedbackSupplier = new DataGridTextColumn();
columnFeedbackSupplier.Binding = new Binding("CheckBoxColumn");


I do not know how to bind/join a
DataGridCheckBoxColumn
with a
DataGridTextColumn
to display both the text and a checkbox in one column

Answer

DataGridTemplateColumn you can define Template for the same.

<DataGridTemplateColumn Header="ViewQuote">
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Supplier}"/>
                <CheckBox IsChecked="{Binding TrueFalse}"/>
            </StackPanel>
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Comments