Click or drag to resize
AB4D logo

DXViewCreateObjectNames Method

CreateObjectNames uses reflection on parentObject (Window or UserControl) to get the names of internal fields that are created from XAML. This method calls Collect3DObjectNames method.

Namespace: Ab3d.DirectX.Controls
Assembly: Ab3d.DXEngine.Wpf (in Ab3d.DXEngine.Wpf.dll) Version: 7.1.9105.2048
Syntax
C#
public void CreateObjectNames(
	Object parentObject
)

Parameters

parentObject  Object
parentObject (Window or UserControl)
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 DXViewChild. In this case we add the field's value (object instance) and its name (field name) into a dictionary.

Creating object names is done with Collect3DObjectNames(Object) method.

See Also