我在堆栈面板和网格中有3个datagrid,我需要在滚动查看器中添加。当我尝试将滚动查看器添加到网格或堆栈面板时,没有任何反应。当我使用滚动查看器环绕整个堆栈面板和网格时,它可以工作,但它将滚动条放在页面的一边,与datagrids分开。我需要的是网格/堆栈面板将所有三个网格一起滚动(我不希望每个数据网格都滚动;我需要它们保持组合在一起)。以下是我目前的代码。谢谢!
<StackPanel Margin="10,162,0,50" HorizontalAlignment="Left" Width="365">
<Grid>
<Rectangle Fill="{StaticResource BaseColor}"
Stroke="Gray"
RadiusX="10"
RadiusY="10"
Margin="0,0,0,0" />
<StackPanel x:Name="IdentifyResultsStackPanel"
Margin="15,10,15,10"
Visibility="Collapsed">
<TextBlock Text="ELEMENTARY SCHOOL ATTENDANCE AREA:"
Foreground="White"
FontSize="14"
FontStyle="Italic"
Margin="0,0,0,5" />
<slData:DataGrid x:Name="IdentifyDetailsDataGrid"
AutoGenerateColumns="False"
LoadingRow="IdentifyDetailsDataGrid_LoadingRow"
HeadersVisibility="None" >
<slData:DataGrid.Columns>
<slData:DataGridTextColumn Binding="{Binding Path=Key}" FontWeight="Bold"/>
<slData:DataGridTextColumn Binding="{Binding Path=Value}"/>
</slData:DataGrid.Columns>
</slData:DataGrid>
<TextBlock Text="MIDDLE SCHOOL ATTENDANCE AREA:"
Foreground="White"
FontSize="14"
FontStyle="Italic"
Margin="0,0,0,5" />
<slData:DataGrid x:Name="IdentifyDetailsDataGrid2"
AutoGenerateColumns="False"
LoadingRow="IdentifyDetailsDataGrid_LoadingRow"
HeadersVisibility="None" >
<slData:DataGrid.Columns>
<slData:DataGridTextColumn Binding="{Binding Path=Key}" FontWeight="Bold"/>
<slData:DataGridTextColumn Binding="{Binding Path=Value}"/>
</slData:DataGrid.Columns>
</slData:DataGrid>
<TextBlock Text="HIGH SCHOOL ATTENDANCE AREA:"
Foreground="White"
FontSize="14"
FontStyle="Italic"
Margin="0,0,0,5" />
<slData:DataGrid x:Name="IdentifyDetailsDataGrid3"
AutoGenerateColumns="False"
LoadingRow="IdentifyDetailsDataGrid_LoadingRow"
HeadersVisibility="None" >
<slData:DataGrid.Columns>
<slData:DataGridTextColumn Binding="{Binding Path=Key}" FontWeight="Bold"/>
<slData:DataGridTextColumn Binding="{Binding Path=Value}"/>
</slData:DataGrid.Columns>
</slData:DataGrid>
</StackPanel>
</Grid>
</StackPanel>
答案 0 :(得分:0)
stackpanel就是问题所在。以下链接帮助我解决了这个问题: