【发布时间】:2018-04-05 18:00:42
【问题描述】:
所以我开始学习 UWP 编程并学习如何使用 Swipe 方法,我使用了这个链接:Swipe Tutorial 但是在按照他们的步骤进行操作后,我开始收到以下错误:无法在索引 0 处添加子项。 并且我们突出显示了以下代码行
<SwipeItems x:Key="RevealOptions" Mode="Reveal">
<SwipeItem Text="Touch it" IconSource="{StaticResource TouchIcon}"/>
<SwipeItem Text="Eat it" IconSource="{StaticResource EatIcon}"/>
</SwipeItems>
<SwipeItems x:Key="ExecuteBuying" Mode="Execute">
<SwipeItem Text="Buy it" IconSource="{StaticResource BuyIcon}"/>
</SwipeItems>
这是完整的代码:
<Page.Resources>
<SymbolIconSource x:Key="TouchIcon" Symbol="View"/>
<SymbolIconSource x:Key="EatIcon" Symbol="Emoji"/>
<SymbolIconSource x:Key="BuyIcon" Symbol="Like"/>
<SwipeItems x:Key="RevealOptions" Mode="Reveal">
<SwipeItem Text="Touch it" IconSource="{StaticResource TouchIcon}"/>
<SwipeItem Text="Eat it" IconSource="{StaticResource EatIcon}"/>
</SwipeItems>
<SwipeItems x:Key="ExecuteBuying" Mode="Execute">
<SwipeItem Text="Buy it" IconSource="{StaticResource BuyIcon}"/>
</SwipeItems>
</Page.Resources>
<Grid>
<SwipeControl Name="MySwipeContainer"
LeftItems="{StaticResource RevealOptions}"
RightItems="{StaticResource ExecuteBuying}">
<ListView HorizontalAlignment="Center" VerticalAlignment="Center">
<ListViewItem Content="Apple" FontSize="36"/>
<ListViewItem Content="Banana" FontSize="36"/>
<ListViewItem Content="Grape" FontSize="36"/>
<ListViewItem Content="Lemon" FontSize="36"/>
<ListViewItem Content="Melone" FontSize="36"/>
<ListViewItem Content="Watermelon" FontSize="36"/>
</ListView>
</SwipeControl>
</Grid>
【问题讨论】:
-
我遇到了同样的问题 (
Failed to add the child at index 0),我注意到我的解决方案配置设置为ARM。我猜这发生在应用程序包的麻烦构建之后(用于将其部署到其他计算机上)。现在,我想知道为什么 ARM 会给出这个错误。毕竟 UWP 不是那么普遍吗?