2013-05-10 52 views
1

这里我的代码:的ScrollViewer属性“内容”设置不止一次

<Grid Style="{StaticResource LayoutRootStyle}"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="140"/> 
     <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 

    <ScrollViewer 
      Grid.RowSpan="2" Style="{StaticResource HorizontalScrollViewerStyle}" 
      HorizontalScrollBarVisibility="Visible" > 
      <!-- The elements you want to be horizontally scrollable goes here --> 
      <!-- Horizontal scrolling grid used in most view states --> 

     <GridView 
      Name="itemGridView" 
      AutomationProperties.AutomationId="ItemsGridView" 
      AutomationProperties.Name="Items" 
      TabIndex="1" 
      Padding="100,136,116,46" 
      ItemsSource="{Binding Source={StaticResource itemsViewSource}}" 
      ItemTemplate="{StaticResource Standard250x250ItemTemplate}" 
      SelectionMode="None" 
      IsSwipeEnabled="false" 
      IsItemClickEnabled="True" 
      ItemClick="ItemView_ItemClick"/> 

     <Button Hello /> <!-- From here come the Error -->   
    </ScrollViewer> 
</Grid> 

当我添加任何东西我GridView后,它给我的错误(content设置不止一次的属性)。

回答

6

答案就在错误信息中。 A ScrollViewer只能有一个孩子(你有两个,一个GridView和一个Button)。如果您想添加多件物品,您必须将其包装在允许多个孩子的面板中(例如Grid)。