滚动视图控件的属性 'content' 被设置了多次。

4

这是我的代码:

<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被设置了多次)。
1个回答

11
答案就在错误信息里。一个ScrollViewer只能有一个子元素(你有两个,一个是GridView,另外一个是Button)。如果你想添加多个组件,你需要将它们包装在允许多个子元素的面板中(例如Grid)。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接