DataGrid-数据超过时水平滚动条不可见

时间:2018-10-17 07:58:36

标签: wpf xaml

在桌面应用程序中,我在自动模式下启用了水平和垂直滚动条。当网格数据超过网格大小时,仅显示垂直滚动条,但不显示水平滚动条。您能帮忙解决这个问题吗?

<TabItem Header="TabItem1">
    <Grid Margin="10,10,10,10">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"  />
            <RowDefinition Height="150" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>

        <GroupBox Grid.Row="0" BorderBrush="DarkGray" BorderThickness="2" Width="700" HorizontalAlignment="Left" VerticalAlignment="Top" Header="Header1">

        </GroupBox>

        <GroupBox Grid.Row="1" Margin="0,10,0,0" BorderBrush="DarkGray" BorderThickness="2" Height="140" Width="700" HorizontalAlignment="Left" VerticalAlignment="Top" Header=" Header2">
            <Grid Margin="5,5,15,5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="120" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Label Grid.Column="0" Width="120" Style="{StaticResource currentSettingsLabel}" Content="User Roles:"  />

                <DockPanel Grid.Column="1">
                    <Border BorderBrush="DarkGray" Background="White" BorderThickness="2">
                        <!--<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">-->
                        <DataGrid HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" 
                                    Style="{DynamicResource DGHeaderStyle}" Background="White" HeadersVisibility="All" IsHitTestVisible="True"
                                        CanUserResizeRows="False" CanUserResizeColumns="False" CanUserSortColumns="False" IsTextSearchEnabled="True" IsReadOnly="True" CanUserAddRows="False" 
                                        ItemsSource="{Binding Path=UserPermissionList}" CanUserReorderColumns="False" AutoGenerateColumns="False">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Header="Role" Binding="{Binding Path=DisplayName}"/>
                                    <DataGridTextColumn Width="*" Header="Description" Binding="{Binding Path=RoleDescription}"/>
                                </DataGrid.Columns>
                            </DataGrid>
                        <!--</ScrollViewer>-->
                    </Border>
                </DockPanel>
            </Grid>
        </GroupBox>

        <GroupBox Margin="0,10,0,0" Grid.Row="2" BorderBrush="DarkGray" BorderThickness="2" Width="700" HorizontalAlignment="Left" VerticalAlignment="Top" Header=" Header3">
        </GroupBox>
    </Grid>
</TabItem>

0 个答案:

没有答案