首页 新闻 赞助 找找看

win8.1开发,ItemsControl使用ItemContainerStyle时崩溃

0
悬赏园豆:30 [已关闭问题] 关闭于 2016-09-08 09:03

在做win8.1开发的时候,由于在flipview里使用gridview,导致连续滑动时会崩溃,所以想使用ItemsControl来实现gridview的布局,但是在使用时发现,在ItemsControl同时使用ItemContainerStyle跟ItemsSource时,会出现“灾难性错误”,导致崩溃,主要是ItemContainerStyle导致的崩溃,不知道这块该怎么解决,请问各位牛人有什么好的办法吗?下面的代码是网上找的一个列子

<ItemsControl ItemsSource="{Binding Source={StaticResource source}, Path=Items}">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <Grid/>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                            <ItemsControl.ItemContainerStyle>
                                <Style TargetType="ItemsControl">
                                    <Setter Property="Control.VerticalAlignment" Value="Stretch"/>
                                    <Setter Property="Control.HorizontalAlignment" Value="Center"/>
                                </Style>
                            </ItemsControl.ItemContainerStyle>
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Grid RenderTransformOrigin="0.5,0.5">
                                        <Line Stroke="Black" StrokeThickness="10" X1="5" X2="5" Y2="20" />
                                        <Grid.RenderTransform>
                                            <RotateTransform Angle="{Binding}"/>
                                        </Grid.RenderTransform>
                                    </Grid>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
txy0704的主页 txy0704 | 初学一级 | 园豆:89
提问于:2016-06-06 10:21
< >
分享
所有回答(1)
0

把VirtualizingStackPanel 改成StackPanel就可以了

<FlipView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"></StackPanel>
<!--<VirtualizingStackPanel Orientation="Vertical" ></VirtualizingStackPanel>-->
</ItemsPanelTemplate>
</FlipView.ItemsPanel>

txy0704 | 园豆:89 (初学一级) | 2016-09-08 09:02
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册