dimanche 24 avril 2016

get row values on checking checkbox in a wpf datagrid

I am developing a wpf application and i have a "buyer" named datagrid and i want access row values when a checkbox is checked
I have read some questions on stackoverflow but all went over my head, i was not able to understand them as amatuer yet :(
Here is my datagrid xaml code:-

    <DataGrid x:Name="buyer" SelectionMode="Single" HorizontalAlignment="Left" SelectionUnit="FullRow" VerticalAlignment="Top" Height="550" Width="992" HorizontalScrollBarVisibility="Visible" IsReadOnly="True" AutoGenerateColumns="False" FrozenColumnCount="1" Margin="0,45,0,0" SelectionChanged="RowFocus" TargetUpdated="buyer_TargetUpdated">
           <DataGrid.Columns>
                <DataGridTemplateColumn Header="Joining" >
                    <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <CheckBox IsChecked="{Binding IsSelected,UpdateSourceTrigger=PropertyChanged}"/>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
               </DataGridTemplateColumn>
                <DataGridTextColumn Header="ID" Binding="{Binding buy_id}"/>
                 <DataGridTextColumn Header="Name" Binding="{Binding bname}"/>
                 <DataGridTextColumn Header="Number" Binding="{Binding mobileno}"/>
    </DataGrid.Columns>
         </DataGrid>

I have a button on same datagrid window which on clicking should give me values from the rows which i checked
Any help is appreciated

Edit: Currently,i am checking if the checkbox is working by writing in console.




Aucun commentaire:

Enregistrer un commentaire