Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/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
Windows phone 8.1 如何使用c动态更改Flipview对象_Windows Phone 8.1_Win Universal App - Fatal编程技术网

Windows phone 8.1 如何使用c动态更改Flipview对象

Windows phone 8.1 如何使用c动态更改Flipview对象,windows-phone-8.1,win-universal-app,Windows Phone 8.1,Win Universal App,我正在为windows phone开发应用程序。我正在使用flipview显示细节。此flipview包含三个控件,可使用滑动更改视图。我想在单击按钮时更改视图 请参阅我的代码: <FlipView x:Name="flip" Grid.Row="1" Grid.ColumnSpan="4" Grid.Column="0" Margin="0,0,0,0.333" Grid.RowSpan="2"> <FlipViewItem>

我正在为windows phone开发应用程序。我正在使用flipview显示细节。此flipview包含三个控件,可使用滑动更改视图。我想在单击按钮时更改视图

请参阅我的代码:

<FlipView x:Name="flip" Grid.Row="1" Grid.ColumnSpan="4" Grid.Column="0" Margin="0,0,0,0.333" Grid.RowSpan="2">
            <FlipViewItem>
                    <Button Foreground="White" Background="Black" x:Name="btnAdd" Content="Add" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" Tapped="btnAdd_Tapped" ></Button>
            </FlipViewItem>
            <FlipViewItem>
                <Button x:Name="btny2" Content="mov" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" Tapped="btny2_Tapped" ></Button>
            </FlipViewItem>
            <FlipViewItem>
                <Button x:Name="btnUpdate" Content="Upd" Grid.Row="1" Grid.Column="2" HorizontalAlignment="Right" Tapped="btnupdate_Tapped" ></Button>
            </FlipViewItem>
            <FlipViewItem>
                <Button x:Name="btnRemove" Content="Rem" Grid.Row="1" Grid.Column="3" HorizontalAlignment="Center" Tapped="btnRemove_Tapped" ></Button>
            </FlipViewItem>
        </FlipView>




private void btnAdd_Tapped(object sender, TappedRoutedEventArgs e)
        {
            flip.SelectedIndex++;

        }

        private void btnupdate_Tapped(object sender, TappedRoutedEventArgs e)
        {
            flip.SelectedIndex++;
        }

        private void btny2_Tapped(object sender, TappedRoutedEventArgs e)
        {
            flip.SelectedIndex++;
        }

        private void btnRemove_Tapped(object sender, TappedRoutedEventArgs e)
        {
            flip.SelectedIndex++;
        }
but it is not working at all.

单击按钮事件时,只需增加/减少所选索引

private void Button_Click_1(object sender, RoutedEventArgs e)
{
    SelectedIndex++;
}

private void Button_Click(object sender, RoutedEventArgs e)
{
    SelectedIndex--;
}

试试这样的

in.xaml

<FlipView x:Name="flip" Grid.Row="1" Grid.ColumnSpan="4" Grid.Column="0" Margin="0,0,0,0.333" Grid.RowSpan="2">

    <Button Foreground="White" Background="Black" x:Name="btnAdd" Content="Add" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" Tapped="btnAdd_Tapped" ></Button>

    <Button x:Name="btny2" Content="mov" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" Tapped="btny2_Tapped" ></Button>

    <Button x:Name="btnUpdate" Content="Upd" Grid.Row="1" Grid.Column="2" HorizontalAlignment="Right" Tapped="btnupdate_Tapped" ></Button>

    <Button x:Name="btnRemove" Content="Rem" Grid.Row="1" Grid.Column="3" HorizontalAlignment="Center" Tapped="btnRemove_Tapped" ></Button>

</FlipView>

我发现,如果你把按钮放在flipview的外面,然后尝试更改相同的索引,那么它的工作就完成了 请查看以下代码,使用网格或画布,我们可以轻松地将按钮放置在Flipview上

xaml


我已经提过了。增加/减少索引根本不起作用。它以什么方式不起作用?实际行为与期望的行为有何不同?递增SelectedIndex将使页面前进。单击是一个比点击更合适的事件,但除此之外,代码表面上看起来很好。更改flipview flip.UseTouchAnimationsForAllNavigation=false的属性后即为工作;
private void Button_Click_1(object sender, RoutedEventArgs e)
{
    var newItemIndex = (flip.SelectedIndex + 1)
    flip.SelectedIndex = newItemIndex;
}

private void Button_Click(object sender, RoutedEventArgs e)
{
    var newItemIndex = (flip.SelectedIndex - 1)
    flip.SelectedIndex = newItemIndex;
}
 <Grid x:Name="LayoutRoot">



    <FlipView x:Name="SlideHub"  ManipulationMode="Rotate" FlowDirection="LeftToRight"     UseTouchAnimationsForAllNavigation="True" Grid.Row="1"  >

        <FlipViewItem  >

        </FlipViewItem>

        <FlipViewItem  >

        </FlipViewItem>

        <FlipViewItem  >

        </FlipViewItem>

        <FlipViewItem >
        </FlipViewItem>

    </FlipView>


    <Image Tapped="slideBankingNext_tapped" Grid.Row="0" Width="40" Margin="0 10 10 20" HorizontalAlignment="Right" VerticalAlignment="Bottom" Source="/Images/welcome_next.png"  />

</Grid>
 private void slideBankingNext_tapped(object sender, TappedRoutedEventArgs e)
    {
        var newItemIndex = (SlideHub.SelectedIndex + 1);
            SlideHub.SelectedIndex = newItemIndex;
    }