PivotViewer 控件使您能够以容易被用户使用的方式一次性显示大量数据。用户可以以帮助其查看趋势并快速找到他们所需信息的方式来浏览数据.
PivotViewer 显示效果确实不错,普通应用方式可以参考 MSDN帮助PivotViewer的使用 ,但当使用大量图片绑定模版时,会造成Silverlight页面卡死,并占用大量内存,原因是图片还是一次性加载,并不是一个一个加载.
要想分布加载,可以使用老方式 – CXML
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
Cxml与PivotViewer绑定
private CxmlCollectionSource cxml;
private void InitializePivotViewer()
{
string cxamName = string.Empty;
if (!App.Current.Host.InitParams.TryGetValue("CXMLNAME", out cxamName))
{
return;
}
var source = Application.Current.Host.Source;
string url = string.Format("http://{0}:{1}/{2}", source.Host, source.Port, cxamName);
cxml = new CxmlCollectionSource(new Uri(url, UriKind.Absolute));
cxml.StateChanged += _cxml_StateChanged;
}
void _cxml_StateChanged(object sender, CxmlCollectionStateChangedEventArgs e)
{
if (e.NewState == CxmlCollectionState.Loaded)
{
pivotViewer.PivotProperties = cxml.ItemProperties.ToList();
pivotViewer.ItemTemplates = cxml.ItemTemplates;
pivotViewer.ItemsSource = cxml.Items;
}
}
CXML 生成方式,可以是用开源的库.
PivotServerTools.dll
https://preview.nuget.org/packages/pivotserverlib/1.0/Contents