Select to view content in your preferred language

ScrollViewer with multiple datagrids

4447
1
Jump to solution
08-30-2012 10:53 AM
TanyaOwens
Frequent Contributor
Hello,
I have 3 datagrid that in a stackpanel and grid that I need to add in a scroll viewer too. When I try to add the scroll viewer to grid or stack panel nothing happens. When I surround the entire stackpanel and grid with a scroll viewer it works but it put the scroll bar to the side map view separated from the datagrids. What I need is the grid/stackpanel to scroll all three grids together (I don???t want each data grid to scroll; I need them to stay grouped together). Below is my current code. Thanks!

    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible">                 <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>             </ScrollViewer>
0 Kudos
1 Solution

Accepted Solutions
TanyaOwens
Frequent Contributor
0 Kudos
1 Reply
TanyaOwens
Frequent Contributor
The stackpanel was the problem. The following link helped me fix it:
http://stackoverflow.com/questions/2691236/silverlight-scrolling-with-a-stackpanel
0 Kudos