flipviews inside Dynamic listview not swipable

回眸只為那壹抹淺笑 提交于 2019-12-11 03:26:57

问题


I have a listview that is populated during runtime from a webservice. Inside the data template of the listview I have made flipview, each flipview gets three images that user can swipe. I have attached an image of what i am looking for.

ISSUE

The flipview doesnt get user interactions. here is the xaml below

<ListView   ManipulationMode="None" IsZoomedInView="False"  IsSwipeEnabled="False" >
    <ListView.ItemTemplate >
        <DataTemplate>
            <Grid>
                <FlipView ItemsSource="{Binding image}" ManipulationMode="All">
                    <FlipView.ItemTemplate>
                        <DataTemplate>
                            <Image Source="{Binding image}" Stretch="Fill"></Image>
                        </DataTemplate>
                    </FlipView.ItemTemplate>
                </FlipView>
            </Grid>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

回答1:


you have to apply a workaround here.

  • use gridview instead of flipview.
  • edit the template of the gridview(remove it and add (copy/paste) a flipview template instead)

next, the trick,

  • change the target type of pasted tempate to gridview
  • find/replace all other flipview tags inside the template with gridview tags
  • last step,bind this new template to the gridview (inside that listview)



回答2:


You can Add ItemsControl instead of ListView as ListView has some problems with inner controls that use horizontal gestures.

<ItemsControl>
<ItemsControl.ItemTemplate >
    <DataTemplate>
        <Grid>
            <FlipView ItemsSource="{Binding image}" ManipulationMode="All">
                <FlipView.ItemTemplate>
                    <DataTemplate>
                        <Image Source="{Binding image}" Stretch="Fill"></Image>
                    </DataTemplate>
                </FlipView.ItemTemplate>
            </FlipView>
        </Grid>
    </DataTemplate>
</ItemsControl.ItemTemplate>

You may need to add ScrollViewer manually as ItemsControl doesn't have one



来源:https://stackoverflow.com/questions/27917717/flipviews-inside-dynamic-listview-not-swipable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!