我正在尝试创建一个JIT pivotviewer,我有点挣扎了。有人可以清楚我对如何动态创建cxml的困惑吗?还应该如何设置信息来请求它?我现在把它放在我的数据库里面,我是否需要为它加载创建一个xml文件,或者它可以直接从数据库中提取它吗?
答案 0 :(得分:0)
要构建 JIT PivotViewer集合,首先要下载Microsoft构建的JIT example。
在解决方案中查看,开始时最重要的一点是CollectionFactories
项目。要使用数据库中的数据创建集合,您需要创建自定义CollectionFactory
。
您的自定义collectionfactory扩展了CollectionFactoryBase
类:
class MyCustomCollection : CollectionFactoryBase
该类需要实现MakeCollection
方法,此方法所要做的就是创建Collection
类的实例并向其添加CollectionItems
。
public override PivotServerTools.Collection MakeCollection(CollectionRequestContext context) {
return MakeCollection();
}
private static PivotServerTools.Collection MakeCollection() {
PivotServerTools.Collection collection = new PivotServerTools.Collection();
collection.Name = "MyImages";
ItemImage[] fileList = ImageListFromDatabase();
foreach (ItemImage image in fileList) {
collection.AddItem(image.Name, image.ImageUrl.ToString(), image.Description, image, null);
}
return collection;
}
现在要使用此集合并查看其实际操作,您需要在解决方案中为PivotViewer Silverlight应用程序(name of the collection
)提供PivotServer
:
<强>的Default.aspx 强>
<param name="initParams" value="cxml=MyImages.cxml" />