I am trying to embed a SketchFlow prototype in a PRISM region, i am successful in getting the sketchflow player visuals to render but it appears that the Sketch.Flow data is not loaded. I see a number of binding exceptions on the NavigationViewModel.
I know it may not be officially supported but I would like to host multiple sketchflows within a single Silverlight application so I can easily deploy new SketchFlow XAPs and display whichever one I so choos开发者_Go百科e.
There isn't quite enough info provided in your question to know for sure, but I suspect it has to do with how the SketchFlow Player finds the Sketch.Flow data file.
If you look at how a regular SketchFlow project is structured, you have a main app, and a second assembly containing the screens for the project. In the app.xaml.cs file of the main app, there is a line that looks like this:
[assembly: Microsoft.Expression.Prototyping.Services.SketchFlowLibraries("SilverlightPrototype1.Screens")]
That line defines where the SketchFlow Player will look for the data it expects. I haven't tried what you are doing, but that attribute will probably need to be set on your main, or the loading assembly that hosts the SketchFlow Player.
Please note that this is not officially supported in any way, I'm just trying to help find a solution for you.
The first step is to construct an instance of the 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;
Simply constructing a PlayerWindow is not enough. The player window has code inside of it that unfortunately uses the CallingAssembly to locate the Sketch.Flow content and de-serialize it. Below I have modified the code I found in the Microsoft PlayerWindow class to do this to use a specified assembly instead of the one derrived from the 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);
}
Once I get the deserialized Sketch.Flow content back I think I need to re-initialize the PlayerWindow's NavigationViewModel using that data and the other view models, MiniFlowGraphViewModel, AnnotationViewModel, BrandingModel, as well as update 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);
Unfortunately it appears that the DesignTimeAnnotations property on PLayerWindow is either internal or private so I am not sure how I can update it.
Doing the above will get me a SketchFlow Player inside of the region with the navigation display showing that I am currently on "Screen 1". However, the main screen display area is blank and the left hand control panels are not working. I get a variety of BindingExpression errors on NavigationViewModel, BrandinModel and FlowGraphModel.
- Zoom
- DockedControls
- CollapsedControls
- SharedInkStrokes
- InkVisibility
- InkEditingMode
- IsInkEditModeNone
- IsMapOpen
- IsFlowOverviewOpen
精彩评论