Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have a Listbox in which I have added two controls i.e a Checkbox and a Datagrid side by side as a Listboxitem. I have done it in a following manner:

In Code behind:
listBox1.items.Add(dt)

here dt is the table name.

In Xaml:

<listbox grid.row="0" alternationcount="2" minheight="305" horizontalalignment="Stretch" name="listBox1" verticalalignment="Stretch" minwidth="537">
<listbox.itemtemplate>
<datatemplate>
<stackpanel name="stkPanel" minheight="80" minwidth="500" horizontalalignment="Stretch" verticalalignment="Stretch">
<grid>
<grid.columndefinitions>
<columndefinition width="40"> <columndefinition width="Auto">
<datagrid grid.column="1">
AutoGenerateColumns="True"
MinHeight="75"
HorizontalAlignment="Center"
Name="dataGrid1"
VerticalAlignment="Stretch"
MinWidth="470"
MaxWidth="900"
ItemsSource="{Binding}"
IsReadOnly="True" removed="#E6BAB7B7">
<datagrid.columnheaderstyle>
<Style TargetType="DataGridColumnHeader">
<setter property="ContentTemplate">
<setter.value>
<datatemplate>
<checkbox name="colCheckBox" ischecked="{Binding IsChecked, ElementName=IsDone, Mode=OneWay}" content="{Binding}">



</Style>


<checkbox grid.column="0" height="35" width="25" name="IsDone" horizontalalignment="Right" verticalalignment="Center" checked="IsDone_Checked">





Suppose for first listboxitem, there is "IsDone" checkbox and a datagrid. If I select "IsDone" check box (listbox item) all the datagrid column header check box is selected.Now, I can uncheck some of the datagrid coulmn header check boxes.What I want is to get values of the entire column only whose columnheader check box is checked and bind those values to a datatable.Similarly for other listbox item.Can you please suggest me how to do that in wpf?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900