How to bind How to bind that Visual3DCollection to an ObservableCollection?

Aug 25, 2014 at 3:37 AM
HelixToolkit.wpf.SphereVisual3D ->has a-> System.Windows.Media.Media3D.Visual3DCollection
Q: How to bind that Visual3DCollection to an ObservableCollection?

How can I use an ObservableCollection as my collection of <Object>.Children ?

I mean, instead of always using someCube.Children.Add(<someObject>), why can't I, or how can I, simply bind (like everything else in WPF) a collection to the Visual3DCollection (or whatever other mechanism exists), and manipulate the ObservableCollection?

We do this with other WPF objects, and since I'm having a hell of a time with my app crashing constantly, I'm hoping there is a way to simplify all of this...

Your thoughts?

(the issue worsded a different way below)

Using Helix toolkit, but might apply to generic WPF. How can I use an observablecollection to manage objects as children of a WPF object?

An object like Helixtoolkit.wpf.cubevisual3d can have:


The visual3d object, and it's children, do not have an ItemsSource() property to bind to like datagrids do. Even if the updating of the visual3d object (the one with the children) has to be done manually (not via ObsColl itemchanged, etc. events), managing all the children in a collection seems easiest.

Since i only know how to use ObsColl's like this, is there an equivelent, or viable workaround, for a Visual3d/model3d object (whether or not Helix, but helix is very convenient)?
Aug 25, 2014 at 7:58 PM
This is interesting, and I would like to know it too.

But I think that binding collections is not allowed at this moment in Helix...
Aug 25, 2014 at 9:04 PM
The Children property is readonly:

But you can probably do this with an attached dependency property or derive a class and create an ItemsSource property where you synchronize the changes to the collection with the Children collection...

See also the Source\Examples\WPF\ExampleBrowser\Examples\DataTemplate for some ideas on templating 3D content!
Aug 25, 2014 at 9:35 PM

If the Children property is read-only, then why can I do:

SomeObject.Children.Add(someOtherObject) ?

Isn't Children a collection?
Aug 25, 2014 at 10:20 PM
The property is read-only, so you cannot bind Children to your observable collection as we do with ItemsSource on other WPF elements (based on ItemsControl).

ps. Posting the question on stack overflow may be worth a try for general questions like this! :-)
Aug 26, 2014 at 1:19 AM
Got no takers (none) on SO. What is acceptable, though, is to maintain a collection, then completely replace the existing one via code (versus elaborate events, as is typical in OCs..

What I mean is, I can easily create & maintain my collection of objects in code (I am stuck for 2 weeks now at this stage, so this is not pointless theory discussion), and then as my code sees fit (after a significant change, timer, etc. the code would REPLACE the existing Children() collection.

It isn't binding, I don't think (since binding isn't apparently possible-which is an even stranger situation/restriction), but more like in one frame it displays CollectionA, and the next frame it shows CollectionB. Right now, even writing on the UI thread, I am crashing my app after about 4 seconds of running. And by crashing, I mean the app leaves no log trace of what it does, and goes back to with that idiotic "incorrect number of parameters', which nobody knows anything about or understands.

I need to add a few to hundreds of children to an object, and manage them (they fade over time, then go away after they are transparent. I know WPF doesn't like collections being changed by non-UI threads, but I can't see any of that happening. I'm desperate at this point, which is why I am at the point we're at now.

I will be testing how this works out, but until then if anyone has any input, it would be great.

I can't continue (been stuck ~17 days now) until I get past this, and I don't want to get rid of Helix and do it 'bare bones'. My app is a simple WPF project, I should be able to do this with high level tools.
Aug 26, 2014 at 1:31 AM
Also, does anyone know how I can use the Content attribute in this scenario?

SomeSphere as SphereVisual3D has children:


SomeSphere.Content being System.Windows.Media.Media3D.Model3D:

SomeSphere.Content.*, which includes .Traverse() and .Transform()...

Any of this give anyone any ideas?