Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to create a simple Datagrid using WPF such that each row has a checkbox. I am having a tough time while retrieving the data. I am getting only 1 result. What can I fix in the below XAML
<DataGrid x:Name="details" x:Uid="MyDataGrid" AutoGenerateColumns="False" AlternationCount="1" SelectionMode="Single" IsReadOnly="True" HeadersVisibility="Column" Margin="0,0,10,2" HorizontalAlignment="Right" Width="410" Grid.Column="1" Grid.Row="1" >
           <DataGrid.Columns>
               <DataGridTemplateColumn>
                   <DataGridTemplateColumn.Header>
                       <CheckBox Content=" Select All" x:Name="headerCheckBox" />
                   </DataGridTemplateColumn.Header>
                   <DataGridTemplateColumn.CellTemplate>
                       <DataTemplate>
                           <CheckBox Name="chkDiscontinue"  IsChecked="{Binding Path=IsChecked,ElementName=headerCheckBox,Mode=OneWay}"   Margin="45 2 0 0"  />
                       </DataTemplate>
                   </DataGridTemplateColumn.CellTemplate>
               </DataGridTemplateColumn>
               <DataGridTextColumn Binding="{Binding Path=file_name}" Header="File Name" Width="2*" IsReadOnly="True" />
               <DataGridTextColumn Binding="{Binding Path=file_path}" Header="File Path" Width="0.9*"/>
          </DataGrid.Columns> </DataGrid>


What I have tried:

Have been expreimenting with above XML from last 2 days
Posted
Updated 8-Jul-18 20:00pm

1 solution

I answered almost an identical question to this one yesterday. Rather than repost the same answer, you can read my solution here:

How to check WPF datagrid checkbox is selected or not in all rows in button click event[^]
 
Share this answer
 

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