Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 未能在索引0处添加子级_C#_Uwp_Swipe_Uwp Xaml - Fatal编程技术网

C# 未能在索引0处添加子级

C# 未能在索引0处添加子级,c#,uwp,swipe,uwp-xaml,C#,Uwp,Swipe,Uwp Xaml,因此,我开始学习UWP编程,并学习如何使用我使用此链接的滑动方法: 但在遵循他们的步骤之后,我开始收到以下错误:未能在索引0处添加子级。下面几行代码突出显示 <SwipeItems x:Key="RevealOptions" Mode="Reveal"> <SwipeItem Text="Touch it" IconSource="{StaticResource TouchIcon}"/> <SwipeI

因此,我开始学习UWP编程,并学习如何使用我使用此链接的滑动方法: 但在遵循他们的步骤之后,我开始收到以下错误:未能在索引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>

从文档中,它将SwipeControl放入数据模板中,因此,您需要使用SwipeControl包装listviewitem而不是ListView。您的代码需要以下内容:

<ListView HorizontalAlignment="Center" VerticalAlignment="Center">
            <SwipeControl 
                  LeftItems="{StaticResource RevealOptions}"
                  RightItems="{StaticResource ExecuteBuying}">
                <ListViewItem Content="Apple" FontSize="36"/>
            </SwipeControl>
            <SwipeControl 
                  LeftItems="{StaticResource RevealOptions}"
                  RightItems="{StaticResource ExecuteBuying}">
                <ListViewItem Content="Banana" FontSize="36"/>
            </SwipeControl>
            <SwipeControl 
                  LeftItems="{StaticResource RevealOptions}"
                  RightItems="{StaticResource ExecuteBuying}">
                <ListViewItem Content="Grape" FontSize="36"/>
            </SwipeControl>
            <SwipeControl 
                  LeftItems="{StaticResource RevealOptions}"
                  RightItems="{StaticResource ExecuteBuying}">
                <ListViewItem Content="Lemon" FontSize="36"/>
            </SwipeControl>
            <SwipeControl 
                  LeftItems="{StaticResource RevealOptions}"
                  RightItems="{StaticResource ExecuteBuying}">
            <ListViewItem Content="Melone" FontSize="36"/>
            </SwipeControl>
            <SwipeControl
                  LeftItems="{StaticResource RevealOptions}"
                  RightItems="{StaticResource ExecuteBuying}">
                <ListViewItem Content="Watermelon" FontSize="36"/>
            </SwipeControl>
</ListView>


这是有道理的,但即使在使用代码之后,我仍收到以下错误:资源“ExecuteBuying”的类型不兼容。资源“RevealOptions”的类型不兼容。能否在visual studio中构建和调试应用程序?我也面临这个问题,因为有些类是从16299年引入的(例如,SymbolicConsource)。但若你们在16299系统上运行你们的应用程序,它不会影响你们的应用程序。您的应用仍将能够成功运行。此
未能在索引0处添加子项仍然是一个问题。甚至当我运行应用程序时,我得到的是一个扭曲的视图,当我悬停时,滑动按钮会永久地粘在项目的顶部。绝对不是应该发生的事。。。难怪开发人员不为UWP编写应用程序(甚至不考虑整个框架的糟糕设计)。我也遇到了同样的问题(
未能在索引0处添加子项),我注意到我的解决方案配置设置为
ARM
)。我猜这是在一个麻烦的应用程序包构建(用于在其他计算机上部署)之后发生的。现在,我想知道为什么ARM会给出这个错误。UWP毕竟不是那么普遍吗?