I am not sure what you are trying to achieve but it seems to me like you have an exercise in data binding. Here is an example that may be helpful.
<Window x:Class="ItemControls.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ItemControls" xmlns:system="clr-namespace:System;assembly=System.Runtime"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="400">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition />
</Grid.RowDefinitions>
<UniformGrid Grid.Row="1" Margin="2,4,4,2" HorizontalAlignment="Center" Rows="1" Columns="2" >
<Button x:Name="AddItemButton" Margin="5,2" Padding="5,5"
Content="_Add Item" Click="AddItemButton_Click" />
<Button x:Name="CloneButton" Margin="5,2" Padding="5,5"
Content="_Clone" Click="CloneButton_Click" />
</UniformGrid>
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<ListBox Margin="10,10,0,10" Name="listBox1" HorizontalAlignment="Center" VerticalAlignment="Top" Width="190" Height="190"/>
</ScrollViewer>
</Grid>
</Window>
The main window has a list box and two buttons. Clicking the Add Item button adds a text box to the list. Clicking the clone button adds a cloned text box to the list. Cloned text boxes are bound to the same text property in the view model so updating one clone will change other clones to the same value. Here is the view model.
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace ItemControls
{
public class ItemsVM : INotifyPropertyChanged
{
private string textProperty;
public ItemsVM()
{
TextProperty = "Cloned";
}
public string TextProperty
{
get { return textProperty; }
set
{
textProperty = value;
OnPropertyChanged();
}
}
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected virtual void OnAllPropertiesChanged()
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(null));
}
#endregion
}
}
The code behind handles the button clicks.
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
namespace ItemControls
{
public partial class MainWindow : Window
{
private Binding cloneBinding;
private int id = 1;
public MainWindow()
{
InitializeComponent();
ItemsVM itemsVM = new ItemsVM();
DataContext = itemsVM;
cloneBinding = new Binding("TextProperty");
cloneBinding.Source = itemsVM;
}
private void AddItemButton_Click(object sender, RoutedEventArgs e)
{
listBox1.Items.Add(new TextBox() { Text = $"Hello from number {id}" });
id++;
}
private void CloneButton_Click(object sender, RoutedEventArgs e)
{
var clonedTextBox = new TextBox();
clonedTextBox.SetBinding(TextBox.TextProperty, cloneBinding);
listBox1.Items.Add(clonedTextBox);
}
}
}