0

我需要设置 MinHeight DataGrid 的垂直滚动条。

但是为什么我的数据网格不这样做呢?

这是我的一些代码。

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" MinHeight="{Binding ElementName=listView1, Path=MinHeight}"/>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" MinHeight="{Binding ElementName=listView2, Path=MinHeight}"/>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions> .....

     <Grid Grid.Row="4">
            <DataGrid ColumnHeaderStyle="{StaticResource MyColumnHeader}" Style="{DynamicResource DataGridStyle}"                 
                  x:Name="incidentList" ColumnWidth="*"
                  Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualHeight}"
                  HorizontalAlignment="Stretch" MinHeight="150" SelectedItem="{Binding SelectIcdtRow}"
                  ItemsSource="{Binding m_IncidentListData, UpdateSourceTrigger=PropertyChanged}" AutoGenerateColumns="False" CanUserAddRows="False">
            .........

 <Grid Grid.Row="8">
    <DataGrid  x:Name="listView2" ItemsSource="{Binding m_ResourceList}" HorizontalAlignment="Stretch"                    
              Style="{DynamicResource DataGridStyle}" ColumnHeaderStyle="{StaticResource MyColumnHeader}" 
               ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto"
              MinHeight="150" Margin="0,10,0,10" VerticalAlignment="Stretch"  AutoGenerateColumns="False" CanUserAddRows="False">

Grid.Row="4" 处的DataGrid 可以制作垂直滚动条,而Grid.Row="8" 处的DataGrid 不行。

所以我使用了scrollViewer,但它也没有制作滚动条。请帮我。

4

1 回答 1

0

<ScrollViewer Height="Auto" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"> <Grid Grid.Row="8"> ... Your code ... </Grid> </ScrollViewer>

试试这个,如果你只需要垂直 ScrollViewer 或水平 ScrollViewer。

于 2017-04-20T19:16:21.897 回答