public virtual void LoadWindowControls(StackPanel control, string parent, string name, Type type, object[] attributes, T obj) { //go through all members and add for them //control starts off clean; this is the control that will have all member controls on it try { List <MemberInfo> myFields = type.GetEditableMembers(); List <List <MemberInfo> > tieredFields = new List <List <MemberInfo> >(); for (int ii = 0; ii < myFields.Count; ii++) { if (myFields[ii].GetCustomAttributes(typeof(NonEditedAttribute), false).Length > 0) { continue; } if (myFields[ii].GetCustomAttributes(typeof(NonSerializedAttribute), false).Length > 0) { continue; } object member = myFields[ii].GetValue(obj); if (member == null && myFields[ii].GetCustomAttributes(typeof(NonNullAttribute), false).Length > 0) { throw new Exception("Null class member found in " + type.ToString() + ": " + myFields[ii].Name); } if (myFields[ii].GetCustomAttributes(typeof(SharedRowAttribute), false).Length == 0) { tieredFields.Add(new List <MemberInfo>()); } tieredFields[tieredFields.Count - 1].Add(myFields[ii]); } for (int ii = 0; ii < tieredFields.Count; ii++) { if (tieredFields[ii].Count == 1) { MemberInfo myInfo = tieredFields[ii][0]; StackPanel stack = new StackPanel(); control.Children.Add(stack); DataEditor.LoadMemberControl(name, obj, stack, myInfo.Name, myInfo.GetMemberInfoType(), myInfo.GetCustomAttributes(false), myInfo.GetValue(obj), false); } else { Grid sharedRowPanel = getSharedRowPanel(tieredFields[ii].Count); control.Children.Add(sharedRowPanel); for (int jj = 0; jj < tieredFields[ii].Count; jj++) { MemberInfo myInfo = tieredFields[ii][jj]; StackPanel stack = new StackPanel(); sharedRowPanel.Children.Add(stack); stack.SetValue(Grid.ColumnProperty, jj); DataEditor.LoadMemberControl(name, obj, stack, myInfo.Name, myInfo.GetMemberInfoType(), myInfo.GetCustomAttributes(false), myInfo.GetValue(obj), false); } } } } catch (Exception e) { DiagManager.Instance.LogError(e); } }