为什么我的 ItemsControl 在 ExpandView 内时会被截断
我有一个 WP7 项目,已经困扰我很多天了。任何帮助解决这个问题的帮助将不胜感激。
基本上,我有一个 ScrollViewer。里面我有一个 ItemsControl。 ItemsControl 的 ItemTemplate 包含一个 Expander(改编自 Silverlight 3 Toolkit)。 Expander ContentTemplate 有一个 ItemsControl。
基本上,发生的情况是,当我展开 Expander 项目之一并且 ItemsControl 包含大量项目(> 25)时,列表的“渲染”似乎被截断。项目应该放置的地方有一个很大的空白空间,因此似乎为它们保留了空间,但尽管我尽力了,它们只是被截断了。
我尝试过三种不同类型的 Expander 控件,包括 ExpanderView。无论我尝试什么,结果都是一样的。
这是屏幕截图:http://www.IntuitiveWebDesigns.com/Photos/truncation.png
这是我正在使用的 XAML 的片段。
<ScrollViewer Grid.Row="1">
<ItemsControl ItemsSource="{Binding Publishers}" Margin="0,10,0,0" Height="Auto">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Background="Black" Opacity="60" OpacityMask="#8A000000" CornerRadius="10">
<controlToolkit:Expander ExpandDirection="Down" Header="{Binding}" Content="{Binding}" Height="Auto">
<controlToolkit:Expander.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding PublisherName}"
Foreground="{StaticResource PhoneAccentBrush}"
FontSize="{StaticResource PhoneFontSizeExtraLarge}"
FontFamily="{StaticResource PhoneFontFamilySemiLight}"/>
</DataTemplate>
</controlToolkit:Expander.HeaderTemplate>
<controlToolkit:Expander.ContentTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding Issues}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding TitleAndIssue}"
Foreground="{StaticResource PhoneForegroundBrush}"
FontSize="{StaticResource PhoneFontSizeNormal}"
FontFamily="{StaticResource PhoneFontFamilySemiLight}"/>
<TextBlock Text="{Binding StrAmount}"
TextWrapping="Wrap"
Margin="0,0,0,0"
Foreground="{StaticResource PhoneAccentBrush}"
FontSize="{StaticResource PhoneFontSizeNormal}"
FontFamily="{StaticResource PhoneFontFamilyNormal}"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</controlToolkit:Expander.ContentTemplate>
</controlToolkit:Expander>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
I have a WP7 project that has been giving me the runaround for too many days now. Any help in sorting this out would be hugely appreciated.
Basically, I have a ScrollViewer. Inside I have an ItemsControl. The ItemTemplate for the ItemsControl contains an Expander (adapted from the Silverlight 3 Toolkit). The Expander ContentTemplate has an ItemsControl.
Basically, what is happening is that when I expand one of the Expander items and that ItemsControl contains a larger amount of items (> 25), the "rendering" of the list appears to be truncated. There is a large empty space where the items should go, so there appears to be space reserved for them, but try as I might, they simply get truncated.
I've tried with three different types of Expander controls including the ExpanderView. Same results no matter what I try.
Here is a screenshot: http://www.IntuitiveWebDesigns.com/Photos/truncation.png
Here is a snippet from the XAML I am using.
<ScrollViewer Grid.Row="1">
<ItemsControl ItemsSource="{Binding Publishers}" Margin="0,10,0,0" Height="Auto">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Background="Black" Opacity="60" OpacityMask="#8A000000" CornerRadius="10">
<controlToolkit:Expander ExpandDirection="Down" Header="{Binding}" Content="{Binding}" Height="Auto">
<controlToolkit:Expander.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding PublisherName}"
Foreground="{StaticResource PhoneAccentBrush}"
FontSize="{StaticResource PhoneFontSizeExtraLarge}"
FontFamily="{StaticResource PhoneFontFamilySemiLight}"/>
</DataTemplate>
</controlToolkit:Expander.HeaderTemplate>
<controlToolkit:Expander.ContentTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding Issues}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding TitleAndIssue}"
Foreground="{StaticResource PhoneForegroundBrush}"
FontSize="{StaticResource PhoneFontSizeNormal}"
FontFamily="{StaticResource PhoneFontFamilySemiLight}"/>
<TextBlock Text="{Binding StrAmount}"
TextWrapping="Wrap"
Margin="0,0,0,0"
Foreground="{StaticResource PhoneAccentBrush}"
FontSize="{StaticResource PhoneFontSizeNormal}"
FontFamily="{StaticResource PhoneFontFamilyNormal}"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</controlToolkit:Expander.ContentTemplate>
</controlToolkit:Expander>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您遇到了平台的限制。具体来说,UIElement 在任一维度上都不能大于 2048px。由于内存和性能原因,存在此限制。
不要构建自己的控件,而是尝试使用标准控件之一,或者手机版本的控件之一工具包。
如果您确实想使用扩展器样式控件,请为可滚动区域保留较小的固定大小并虚拟化显示的列表。
You're hitting a limitation of the platform. Specifically that a UIElement can't be larger than 2048px in either dimension. This limitation exists for memory and performance reasons.
Rather than building your own control, try using one of the standard ones, or one from the phone version of the toolkit.
If you really want to use an expander style control, then reserve a smaller fixed size for the scrollable area and virtualize the list that is displayed.