我正在寻找一个事件(或其他机制/解决方法),我可以用它来知道何时在Pivot Viewer控件中完成了交易卡的呈现。我正在使用该控件的SL5版本并添加到它的ItemSource中(通过一个可观察的集合)。目前,在为控件提供数据和在透视查看器控件上看到一些动画之间存在相当大的延迟。填充ItemSource的线程退出,在盯着空白屏幕5-10秒后,用户最终看到了交易卡图像。内置事件不支持交易卡图像的渲染处于“就绪”状态的任何指示。
发布于 2012-12-06 04:03:29
我也有同样的问题,所以我通过扩展pivotviewer控件编写了自己的解决方案:http://stevenhollidge.blogspot.ch/2012/12/pivotviewer-itemsloaded-event.html
我希望有人会觉得这很有用!
发布于 2012-04-10 04:47:56
我对此进行了调查(与PivotViewer开发人员交谈),目前还没有任何东西可以处理,以确定渲染何时完成。
对你来说,最好的选择可能是调查SL渲染性能,并在加载集合后查找drop。不是很漂亮,而且可能无论如何都不会工作。
起点:http://msdn.microsoft.com/en-us/library/bb980092.aspx
杰森·R·谢弗,PivotViewer的前一任PM
发布于 2013-01-07 14:48:35
我发现检测视觉效果何时加载的最好方法是找到MultiScaleImage对象,并检测图像是“正在下载”还是“空闲”,以及图像的视区是什么:
下面是在SL5中如何在PivotViewer上获取对象:
创建PivotViewer对象的子类,并将以下内容放在OnApplyTemplate()覆盖中:
PartContainer = (Grid)this.GetTemplateChild("PART_Container");
cvv = (PartContainer).Children[2] as CollectionViewerView;
if (cvv != null)
{
cvvm = ViewBehaviors.GetViewModel(cvv);
Grid container = cvv.Content as Grid;
Border viewerBorder = container.Children[1] as Border;
Grid cvGrid = viewerBorder.Child as Grid;
cvc = cvGrid.Children[0] as CollectionViewContainer;
}然后你就有了一个关于cvv的引用-- CollectionViewerView。
在PivotViewer对象上设置ItemsSource时,启动一个计时器,该计时器将每隔300毫秒左右检查一次:
ItemViewerView ivv = ((Grid)(((UserControl)(cvc.Content)).Content)).Children[0] as ItemViewerView;
Grid g = (((Grid)ivv.Content).Children[0] as Grid);
ContentControl cc1 = (g.Children[0] as ContentControl);
if (cc1 != null)
{
Canvas cvs = cc1.Content as Canvas;
if (cvs != null && cvs.Children.Count > 0)
{
var contentControl = cvs.Children[0] as ContentControl;
if (contentControl != null)
{
MultiScaleImage x = contentControl.Content as MultiScaleImage;
bool isIdle = x.Source != null && !x.IsDownloading && x.IsIdle;
// This could be more precise, but the origin is by default set to 99999 when a new image is loaded in - we're watching for when this value changes.
bool inViewPort = x.SubImages[x.SubImages.Count - 1].ViewportOrigin.X < 999999;
// if both of these boolean values are true, then the images will be displaying on the screen.
}
}
}请注意,这是版本为5.0.61118的SL .dll (此代码很可能在将来的版本中崩溃)
https://stackoverflow.com/questions/9074618
复制相似问题