ScatterViewItem class hiearchy changed

Editor
Oct 19, 2010 at 4:17 PM

Another thing they've changed between 1.0 and 1.5 of the surface API is the class hierarchy for scatter view items. In the newer version they inherit from ScatterContentControlBase which is also where stuff like CenterProperty and OrientationProperty is defined (the static fields backing the dependency properties)

This makes it effectively impossible to support both versions of the Surface APIs from the same code if you want to do anything with these properties (such as animating on them or using the ThrowSVI method from Blake.NUI) since the runtime will throw a FieldNotFound exception when it tries to JIT the method using them.

I believe this is due to the fact that during compile time, the compiler understands that ScatterViewItem.CenterProperty actually is on the parent class but if you compile against 1.0 and then run on 1.5 it will not understand this.

/* Will not work if compiled against 1.0 and run against 1.5 */
Blake.NUI.WPF.Utility.AnimateUtility.AnimateElementPoint(svi, ScatterViewItem.CenterProperty, newCenterPoint, fromTime, toTime, ease);
If anyone has any suggestions, I'd love to hear them. I don't even know if this can be solved with a reflection hack :-(

Coordinator
Oct 19, 2010 at 5:53 PM

I know you have seen this post (since you commented) but I'm pretty sure the assembly redirection trick I describe here takes care of the problem you're describing.

http://nui.joshland.org/2010/07/sharing-binaries-between-surface-and.html

In addition, Blake.NUI has separate Blake.NUI.Surface and Blake.NUI.SurfaceToolkit assemblies that reference and compile against the right version of the SDK to provide ThrowSVI functionality.

 

Editor
Oct 20, 2010 at 8:47 AM

Yeah that's an excellent post and the reason I decided to try blake.nui :)

I'm following those guidelines and have my three projects
- "Common" (dll - almost all my views are here)
- "Win7" (exe referencing Common)
- "Surface" (exe referencing Common)

I'm also using the assembly redirection trick to make the runtime use the proper version of the surface DLLs. But during compile time, I'm depending on v1.0 for the common project and if I call ThrowSVI() from the common project the compile time binding to ScatterViewItem.CenterProperty (v1.0) doesn't match what it finds in the runtime version of the assembly (v1.5) and it crashes.

By depending on v1.5 during compile time I'm only reversing the problem and the surface .exe will crash instead.

And, since I'm throwing the SVIs from the common project, choosing the appropriate Blake.NUI.Surface[ToolKit] assembly is not solving the issue (since the choice has to be done at runtime)