DXViewCollect |
public static Dictionary<Object, string> Collect3DObjectNames( Object parentObject )
Unfortuantelly is not possible to read the name of the object that is defined in XAML and has x:Name property (if it is not derived from FrameworkElement - for example Visual3D, Model3D). On the other hand it is not possible to define custom property on non-FrameworkElement objects, that would make the compiler to generate fields from the elements.
So if we would like to name 3D objects (SceneNodes) with the same names that are defined in XAML with x:Name, we need to use a little Reflection trick. We get a list of all internal fields in parent Window, User Control or other object that contains fields created from XAML and check if the field is derived from Visual3D, Model3D or DXSceneViewChild. In this case we add the field's value (object instance) and its name (field name) into a dictionary. This dictionary can than be added to DXSceneView to name the SceneNodes.