2015-07-10 85 views
1

如何正确添加scrollviewer到此布局?将scrollviewer添加到网格

我试着将垂直scrollviewer添加到我的主网格,但它没有奏效。

<!--LayoutRoot is the root grid where all page content is placed--> 
<Grid x:Name="LayoutRoot" Background="White" ScrollViewer.VerticalScrollBarVisibility="Auto"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="Auto"/> 
    </Grid.RowDefinitions> 

    <!--TitlePanel contains the name of the application and page title--> 
    <StackPanel Grid.Row="0" Margin="12,17,0,28"/> 

    <!--ContentPanel - place additional content here--> 
    <Grid x:Name="ContentPanel" Margin="12,167,8,-588" Grid.RowSpan="2"> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="169*"/> 
      <ColumnDefinition Width="287*"/> 
     </Grid.ColumnDefinitions> 

     <telerikPrimitives:RadHubTile HorizontalAlignment="Left" Margin="25,21,0,0" VerticalAlignment="Top" Height="153" Width="168" Background="#25A1DA" Title="Search" Grid.ColumnSpan="2" ImageSource="/Assets/Apps-Magnifier-Metro-icon.png"/> 
     <telerikPrimitives:RadHubTile HorizontalAlignment="Left" Margin="76,21,0,0" VerticalAlignment="Top" Height="153" Width="168" Background="#25A1DA" Grid.Column="1" Title="How It Works"/> 
     <telerikPrimitives:RadHubTile HorizontalAlignment="Left" Margin="25,196,0,0" VerticalAlignment="Top" Height="153" Width="168" Background="#25A1DA" Title="Physiotherapists" Grid.ColumnSpan="2"/> 
     <telerikPrimitives:RadHubTile HorizontalAlignment="Left" Margin="76,196,0,0" VerticalAlignment="Top" Height="153" Width="168" Background="#25A1DA" Title="Articles Of Week" Grid.Column="1"/> 
     <telerikPrimitives:RadHubTile HorizontalAlignment="Left" Margin="25,364,0,0" VerticalAlignment="Top" Height="153" Width="168" Background="#25A1DA" Title="Blog Of Week" Grid.ColumnSpan="2"/> 
     <telerikPrimitives:RadHubTile HorizontalAlignment="Left" Margin="76,364,0,0" VerticalAlignment="Top" Height="153" Width="168" Background="#25A1DA" Title="Pod Casts" Grid.Column="1"/> 
     <telerikPrimitives:RadHubTile HorizontalAlignment="Left" Margin="25,549,0,-111" VerticalAlignment="Top" Height="153" Width="168" Background="#25A1DA" Title="Jobs" Grid.ColumnSpan="2"/> 
     <telerikPrimitives:RadHubTile HorizontalAlignment="Left" Margin="76,549,0,-111" VerticalAlignment="Top" Height="153" Width="168" Background="#25A1DA" Title="Courses" Grid.Column="1"/> 

    </Grid> 
    <telerikPrimitives:RadHubTile HorizontalAlignment="Left" Margin="41,17,0,0" VerticalAlignment="Top" Height="153" Width="168" Background="#25A1DA" Title="About Us"/> 
    <telerikPrimitives:RadHubTile HorizontalAlignment="Left" Margin="255,17,0,0" VerticalAlignment="Top" Height="153" Width="168" Background="#25A1DA" Title="Contact"/> 

</Grid> 

回答

1

您的scrollviewer只能包含1个元素。知道你有让grid滚动,而不是它的内容

它会是这样的:

<ScrollViewer> 
    <Grid x:Name="LayoutRoot" Background="White"> 
     //Content here   
    </Grid> 
</ScrollViewer> 

电网需要滚动。不是里面的控件。