protected void BindAxis3D(Axis3D axis) { FieldInfo[] fields = this.GetType().GetFields(); foreach (FieldInfo field in fields) { DependencyProperty dp = (DependencyProperty)field.GetValue(this); FieldInfo fieldInfo = axis.GetType().GetField(string.Concat(dp.Name, "Property")); if (fieldInfo == null) { fieldInfo = axis.GetType().BaseType.GetField(string.Concat(dp.Name, "Property")); } if (fieldInfo == null) { fieldInfo = axis.GetType().BaseType.BaseType.GetField(string.Concat(dp.Name, "Property")); } DependencyProperty dpAxis = (DependencyProperty)(fieldInfo.GetValue(axis)); Binding bindingTransform = new Binding(dp.Name); bindingTransform.Source = this; bindingTransform.Mode = BindingMode.OneWay; BindingOperations.SetBinding(axis, dpAxis, bindingTransform); } }
internal void AddAxis(Axis3D axis) { axis3DCollection.Add(axis); BindAxis3D(axis); }