I have been struggling for this issue for the last one month. Please Help me out. I have a WPF datagrid (datagrid1) in which i am populating a datatable its working fine, in the same UI i have another WPF datagrid (datagrid2) which is to be populated as the mulitple rows selection from the first datagrid1 , how can we do this? Main problem is i want to bind the rows which are selected (multiple) how do i do? Help Me out please.
<DataGrid Name="dataGridSearchResults"
FontWeight="Normal" AutoGenerateColumns="False"
IsReadOnly="True"
ItemsSource="{Binding SearchResults,Mode=Default}"
SelectedIndex="{Binding SelectedIndexSearchResults}"
SelectionMode="Single" Margin="1,0,0,0"
Height="174" GridLinesVisibility="None" >
<DataGrid.Columns>
<DataGridTextColumn Header="RFC ID" Binding="{Binding RFCID}"></DataGridTextColumn>
<DataGridTextColumn Header="RFC Title" Binding="{Binding RFCTitle}"></DataGridTextColumn>
<DataGridTextColumn Header="RFC Revision" Binding="{Binding RFCRevision}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>`
Thanks NallsKarthi
You just have to bind the ItemsSource
property of your second datagrid to the SelectedItems
property of your first datagrid :
<WPFToolkit:Datagrid x:Name="dg1" ItemsSource="{Binding MySourceFromDatabase}" SelectionMode="Extended"/>
<WPFToolkit:Datagrid x:Name="dg2" ItemsSource="{Binding ElementName=dg1,Path=SelectedItems}" />