Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wpf DataGrid RowDetailsTemplate Scroll

<DataGrid>
  <DataGrid.Columns>
    <DataGridTextColumn Binding="{Binding Path=test}"></DataGridTextColumn>
  </DataGrid.Columns>
  <DataGrid.RowDetailsTemplate>
    <DataTemplate>
     <DataGrid Template="{DynamicResource TemplateDataGridPrintAndExport}"/>
    </DataTemplate>
  </DataGrid.RowDetailsTemplate>
 <DataGrid/>

I have a datagrid like above. Datgrid's row detail template also contains a datagrid. Inner datagrid is filled when the parent one's columns are clicked. My problem is this : if the row detail template datagrid is fulfilled and user mouse hovers on it while scrolling parent datagrid the scroll is not working. User should hover the mouse to the main datagriid to scroll. However, it is not user friendly. How can I prevent inner datagrid behaving in such a way?

like image 212
osmanraifgunes Avatar asked Dec 01 '22 16:12

osmanraifgunes


1 Answers

I found the soultion by trying alternatives :

<DataGrid  ScrollViewer.CanContentScroll="False">
  <DataGrid.Columns>
    <DataGridTextColumn Binding="{Binding Path=test}"></DataGridTextColumn>
  </DataGrid.Columns>
  <DataGrid.RowDetailsTemplate>
    <DataTemplate>
     <DataGrid Template="{DynamicResource TemplateDataGridPrintAndExport}"  IsReadOnly="True" ScrollViewer.CanContentScroll="False"  IsEnabled="False"/>
    </DataTemplate>
  </DataGrid.RowDetailsTemplate>
 <DataGrid/>

The solution is to give ScrollViewer.CanContentScroll="False" attribute to the outer data grid and IsReadOnly="True" ScrollViewer.CanContentScroll="False" IsEnabled="False" attributes to inner datagrid. Now it is scrolling smoothly and accoording to the parent datagrid.

like image 118
osmanraifgunes Avatar answered Dec 09 '22 16:12

osmanraifgunes