我想在PRISM區域嵌入SketchFlow原型,我成功獲取了sketchflow播放器的視覺效果,但看起來Sketch.Flow數據未加載。我在NavigationViewModel上看到了許多綁定異常。以編程方式啓動Sketchflow播放器
我知道它可能沒有官方支持,但我想在單個Silverlight應用程序中託管多個Sketchflow,這樣我可以輕鬆部署新的SketchFlow XAP並顯示我選擇的一個。
我想在PRISM區域嵌入SketchFlow原型,我成功獲取了sketchflow播放器的視覺效果,但看起來Sketch.Flow數據未加載。我在NavigationViewModel上看到了許多綁定異常。以編程方式啓動Sketchflow播放器
我知道它可能沒有官方支持,但我想在單個Silverlight應用程序中託管多個Sketchflow,這樣我可以輕鬆部署新的SketchFlow XAP並顯示我選擇的一個。
在您的問題中提供的信息不夠充分,但我懷疑它與SketchFlow Player如何找到Sketch.Flow數據文件有關。
如果您看看常規SketchFlow項目的結構,您有一個主應用程序,第二個程序集包含項目的屏幕。在主應用程序的文件app.xaml.cs,有一條線,看起來像這樣:
[組件:Microsoft.Expression.Prototyping.Services.SketchFlowLibraries( 「SilverlightPrototype1.Screens」)]
該行定義了SketchFlow Player將在哪裏查找它所期望的數據。我還沒有嘗試過你正在做的事情,但該屬性可能需要設置在您的main或承載SketchFlow Player的加載程序集中。
請注意,這不是以任何方式正式支持,我只是想幫助您找到解決方案。
第一步是構建PlayerWindow的一個實例。
string targetTypeName = "Microsoft.Expression.Prototyping.Workspace.PlayerWindow, Microsoft.Expression.Prototyping.Runtime, Version=4.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; var targetType = Type.GetType(targetTypeName); var view = container.Resolve(targetType) as PlayerWindow;
簡單地構建PlayerWindow是不夠的。播放器窗口中有代碼,不幸的是,它使用CallingAssembly來定位Sketch.Flow內容並對其進行反序列化。下面我修改了我在Microsoft PlayerWindow類中找到的代碼,以便使用指定的程序集而不是CallingAssembly創建的代碼。
string str = string.Format(CultureInfo.InvariantCulture, "/SilverlightPrototype1.Screens;Component/Sketch.Flow", new object[] { PlayerContext.Instance.LibraryName }); StreamResourceInfo resourceStream = Application.GetResourceStream(new Uri(str, UriKind.RelativeOrAbsolute)); if (resourceStream != null) { data = Serializer.Deserialize(resourceStream.Stream); }
一旦我得到的反序列化Sketch.Flow內容後,我想我需要使用數據和其他視圖模型,MiniFlowGraphViewModel,AnnotationViewModel,BrandingModel重新初始化PlayerWindow的NavigationViewModel,以及更新DesignTimeAnnotations 。
PlayerContext.Instance.RuntimeData = data;
view.NavigationViewModel = new NavigationViewModel(data);
view.MiniFlowGraphViewModel = new FlowGraphViewModel();
view.AnnotationViewModel = new AnnotationViewModel(view.NavigationViewModel, data.RuntimeOptions.DisableInking, data.RuntimeOptions.HideDesignTimeAnnotations);
view.BrandingModel = new BrandingModel(data);
PlayerContext.Instance.BrandingModel = new BrandingModel(data);
遺憾的是,似乎在PLayerWindow的DesignTimeAnnotations屬性是內部的或私有,所以我不知道我怎麼可以更新它。
通過上述操作,我可以在區域內看到SketchFlow播放器,導航顯示屏顯示我目前在「Screen 1」上。但是,主屏幕顯示區域爲空白,左側控制面板不工作。我在NavigationViewModel,BrandinModel和FlowGraphModel上收到各種BindingExpression錯誤。
見下嘗試我的回答......我做出我如何試圖加載SketchFlow的球員在該地區提供了很多詳細信息。我覺得我很接近,但我缺少的,可能是一些的的ViewModels或PlayerContext正在做內部的工作。 – markti 2010-11-30 22:48:05