0

我正在寻找一个事件(或其他机制/解决方法),我可以使用它来了解交易卡的渲染何时在 Pivot Viewer 控件中完成。我正在使用控件的 SL5 版本并添加到其 ItemSource(通过可观察的集合)。目前,在向控件提供数据和在枢轴查看器控件上看到动画之间存在相当大的延迟。我的填充 ItemSource 的线程退出,在盯着空白屏幕 5-10 秒后,用户最终会看到交易卡图像。内置事件不支持交易卡图像渲染何时处于“就绪”状态的任何指示。

4

3 回答 3

1

我遇到了同样的问题,所以我通过扩展 pivotviewer 控件编写了自己的解决方案:http: //stevenhollidge.blogspot.ch/2012/12/pivotviewer-itemsloaded-event.html

我希望有人觉得这很有用!

于 2012-12-05T20:03:29.480 回答
0

我发现检测何时加载视觉效果的最佳方法是找到 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(此代码很可能会中断的未来版本)

于 2013-01-07T06:48:35.467 回答
0

我对此进行了调查(与 PivotViewer 开发人员交谈),目前您无法确定渲染何时完成。

对您开放的最佳选择可能是调查 SL 渲染性能并在加载集合后寻找下降。不漂亮,可能无论如何都不起作用......

起点:http: //msdn.microsoft.com/en-us/library/bb980092.aspx

Jason R. Shaver PivotViewer 的前任 PM

于 2012-04-09T20:47:56.237 回答