我需要使用设置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可以制作垂直scrollBar, 但Grid.Row =“8”的DataGrid不能。
所以我使用scrollViewer,但它也没有制作滚动条。请帮我。
答案 0 :(得分:0)
<ScrollViewer Height="Auto" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<Grid Grid.Row="8">
...
Your code
...
</Grid>
</ScrollViewer>
如果您只需要垂直ScrollViewer或水平ScrollViewer,请尝试此操作。