【问题标题】:scrollviewer the property 'content' is set more than oncescrollviewer 属性“内容”被设置了不止一次
【发布时间】:2013-05-04 14:38:29
【问题描述】:

这是我的代码:

<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 设置了不止一次)。

【问题讨论】:

    标签: wpf xaml microsoft-metro


    【解决方案1】:

    答案就在错误消息中。一个ScrollViewer 只能有一个孩子(你有两个,一个GridView 和一个Button)。如果你想添加多个东西,你必须将它们包装在一个允许多个孩子的面板中(例如Grid)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多