可选:当ListVIEw没有准备好时,我希望在ListVIEw上显示一个文本(或可能的Progressbar)并说出“Please Wait …”或“Loading Items …”之类的内容.
XAML:
<ListVIEw x:name="MyListVIEw" VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" HorizontalAlignment="left" Height="577" VerticalAlignment="top" WIDth="902" ScrollVIEwer.HorizontalScrollbarVisibility="auto" Foreground="Black" margin="10,10,0" ScrollVIEwer.CanContentScroll="True" borderBrush="#FFC54B4B" borderThickness="3" Background="White"> <ListVIEw.ItemsPanel> <ItemsPanelTemplate> <WrapPanel MaxWIDth="{Binding (FrameworkElement.ActualWIDth),relativeSource={relativeSource AncestorType=ScrollContentPresenter}}" ItemWIDth="{Binding (ListVIEw.VIEw).ItemWIDth,relativeSource={relativeSource AncestorType=ListVIEw}}" MinWIDth="{Binding ItemWIDth,relativeSource={relativeSource Self}}" ItemHeight="{Binding (ListVIEw.VIEw).ItemHeight,relativeSource={relativeSource AncestorType=ListVIEw}}" /> </ItemsPanelTemplate> </ListVIEw.ItemsPanel></ListVIEw>
编辑:
我试过这个:
List<something> MyList = new List<something>(); ThreadPool.QueueUserWorkItem(_ => { ( Create MyList here...) dispatcher.BeginInvoke(new Action(() => { MyListVIEw.ItemsSource = MyList; })); });
在ListVIEw准备好之前,主窗口仍然没有响应.
解决方法 您使用无法进行UI虚拟化的面板(WrapPanel)(与默认ListVIEw ItemPanel模板中使用的VirtualizingStackPanel不同).这意味着你所有的物品都被渲染,即使是那些目前看不到的物品.据我所知,WPF没有内置的虚拟化包装面板,所以你可以尝试一些免费的虚拟化包装面板(例如- http://virtualwrappanel.codeplex.com/),但我不能说它们有多好,我使用Telerik的版本不是免费的.另一个选项是切换回VirtualizingStackPanel.除此之外,请确保在非UI线程上加载项目(如另一个答案中所述). 总结以上是内存溢出为你收集整理的c# – 将WrapPanel虚拟化为ListView的ItemsTemplate全部内容,希望文章能够帮你解决c# – 将WrapPanel虚拟化为ListView的ItemsTemplate所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)