public EquipmentControl() { InitializeComponent(); for (int i = 0; i < vanity_Grid.RowDefinitions.Count; i++) { AccessoryControl accessoryControl = new AccessoryControl(); accessoryControl.SetBinding(AccessoryControl.DataContextProperty, string.Format("Vanity[{0}]", i)); Grid.SetRow(accessoryControl, i); vanity_Grid.Children.Add(accessoryControl); } for (int i = 0; i < armor_Grid.RowDefinitions.Count; i++) { AccessoryControl accessoryControl = new AccessoryControl(); accessoryControl.SetBinding(AccessoryControl.DataContextProperty, string.Format("Armor[{0}]", i)); Grid.SetRow(accessoryControl, i); armor_Grid.Children.Add(accessoryControl); } for (int i = 0; i < accessory_Grid.ColumnDefinitions.Count; i++) { AccessoryControl accessoryControl = new AccessoryControl(); accessoryControl.SetBinding(AccessoryControl.DataContextProperty, string.Format("Accessories[{0}]", i)); Grid.SetColumn(accessoryControl, i); accessory_Grid.Children.Add(accessoryControl); } }