Search code examples
c#wpfdatagridrowdetails

WFP datagrid rowdetails verticalscrollbar not working


I have a datagrid with rowdetails (also a datagrid). When I expand the rows the verticalscrollbar doesn't show. See screenshot below:

Scrollbar not working

Below is my xmal code for the datagrid

<DataGrid x:Name="MainDtg" ItemsSource="{Binding}" RowDetailsVisibilityMode="Collapsed" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible" AutoGenerateColumns="False" CanUserAddRows="False" Margin="4,4.333,0.333,1" Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="2">
.......
 <DataGrid.Columns>
            <DataGridTextColumn Header="CUSTOMER" IsReadOnly="True" Width="10*" Binding="{Binding CUSTOMER_CODE, UpdateSourceTrigger=PropertyChanged}" />
.....
<DataGrid.RowDetailsTemplate>
            <DataTemplate>
                <DataGrid x:Name="FSdtg" ItemsSource="{Binding Mode=TwoWay, Path=FSCLIST, UpdateSourceTrigger=PropertyChanged}" RowDetailsVisibilityMode="Collapsed" VerticalScrollBarVisibility="Visible"  HorizontalScrollBarVisibility="Disabled" AutoGenerateColumns="False" CanUserAddRows="False" Margin="10,5,0,0">
........

I have tried to set VerticalScrollBarVisibility to other values, such as auto etc. None works. Does anyone know why this is happening? and if there is a solution?

Thank you


Solution

  • One way to deal with this is to put the datagrid in a StackPanel and then a ScrollViewer (in my case not sure why it doesn't work if I only put the datagrid in a scrollviewer. It was just taking forever to load).

    There should be better ways, but this works for me.

    Anyway, hope this helps whoever encounters the same problem.