ExpanderView不显示所有项目

时间:2012-03-29 16:45:05

标签: windows-phone-7 silverlight-toolkit expander

我使用的是WindowsPhone Toolkit的ExpanderView,在第一次加载时,扩展的Expander总是看起来像第二张图片。 看起来,它始终处于所有物品的同一高度。

如果我转到另一页并返回,一切都会很好,布局看起来很安静 - 除了停止扩展器的行(图1)。

this.UpdatedLayout();(当前页面)或ExpanderView.UpdateLayout();解决了什么。 未显示的项目已完全加载到该列表中。

part 1

part 2

<ItemsControl ItemsSource="{Binding EpisodeList}" Margin="20,0,0,0" Grid.Row="1" Grid.ColumnSpan="2">
<ItemsControl.ItemTemplate>
    <DataTemplate>
        <StackPanel>
            <toolkit:ExpanderView ItemsSource="{Binding Value}" >
                <toolkit:ExpanderView.Header>
                    <TextBlock Margin="0,0,10,0">
            <Run Text="Season "/>
            <Run Text="{Binding Key}" />
                    </TextBlock>
                </toolkit:ExpanderView.Header>
                <toolkit:ExpanderView.ItemTemplate>
                    <DataTemplate>
                        <Border BorderBrush="White" BorderThickness="1" Margin="5">
                            <Grid MouseLeftButtonUp="Grid_MouseLeftButtonUp">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <Image Height="40"  Source="{Binding ScreenCap}" Margin="5,0,0,0"/>
                                <TextBlock x:Name="t" Margin="10" Text="{Binding Title}" TextWrapping="Wrap" Grid.Column="1" />
                            </Grid>
                        </Border>
                    </DataTemplate>
                </toolkit:ExpanderView.ItemTemplate>

            </toolkit:ExpanderView>
        </StackPanel>
    </DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

EpisodeList是Dictionary(int,ObservableCollection(myClass))的类型并实现了INotifyPropertyChanged

如果有人有任何计划在这里出错,我真的很感激你的帮助,我只是没有在google上找到任何bug报告,也没有类似的Bug。

(在设备上和模拟器上调试)

2 个答案:

答案 0 :(得分:6)

我设法通过使用列表框作为itemcontainer并将扩展器项绑定到它来解决这个问题:

                    <Controls:ExpanderView Expanded="ExpanderView_Expanded"
                        Header="{Binding}"                               
                        HeaderTemplate="{StaticResource HeaderTemplate}"                                                                             
                        NonExpandableHeader="{Binding}" 
                        ExpanderTemplate="{StaticResource ExpanderTemplate}"
                        NonExpandableHeaderTemplate="{StaticResource NonExpandableHeaderTemplate}"
                        Expander="{Binding}"
                        >
                        <ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled" ItemTemplate="{StaticResource ItemTemplate}" ItemsSource="{Binding Items}" />
                    </Controls:ExpanderView>

答案 1 :(得分:0)

我有与ExpanderView类似的问题。我认为它可能是视图中的一个错误,不知何故与2048px限制有关。基本上当我向扩展的ExpanderView添加了很多项目时,一切都很好,直到我折叠视图并再次展开它。扩展ExpanderView之后,2048像素之后的任何项目都没有显示,除非我点击它们或滚动它们甚至然后它们只在移动时显示(项目的点击动画正在运行或列表是在移动中)。

我注意到,如果我将一个项目添加到ExpanderView或者在展开时从中删除了一个项目,那么故障就会消失,直到下次我折叠并展开项目时,我快速解决了添加和删除问题通过使用ExpanderView的Expanded-和LayoutUpdated-事件扩展视图的虚拟项目。基本上这就是我做的:

  • 设置状态以指示正在进行扩展并存储要扩展的视图供以后使用。 (在Expanded事件处理程序中)
  • 等待直到所有Expanderviews的布局都更新(使用LayoutUpdated事件处理程序跟踪此情况)
  • 将虚拟项添加到已扩展的ExpanderView(在LayoutUpdated事件处理程序中)
  • 等待所有Expanderviews的布局更新
  • 删除虚拟项目(在LayoutUpdated事件处理程序中)

可能是丑陋的解决方案,但我能想出最好的解决方案。希望这对你的问题有所帮助。

编辑: 没有帮助扩展器的停止线。只是无法让那个工作..

相关问题