Click or drag to resize
AB4D logo

DXViewCollect3DObjectNames Method

Collect3DObjectNames gets names of all internal fields in parentObject that contains internal fields defined in XAML (for example Window or UserControl) that are derived from Visual3D, Model3D or DXSceneViewChild and stores them in Dictionary of object as key and object name as value.

Namespace: Ab3d.DirectX.Controls
Assembly: Ab3d.DXEngine.Wpf (in Ab3d.DXEngine.Wpf.dll) Version: 7.0.8865.1045
Syntax
C#
public static Dictionary<Object, string> Collect3DObjectNames(
	Object parentObject
)

Parameters

parentObject  Object
parent object that contains internal fields defined in XAML (for example Window or UserControl)

Return Value

DictionaryObject, String
Dictionary of object as key and object name as value
Remarks

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.

See Also