In your newly create UserControl
, you can just expose the ListBox
via a property. Then you can access the ListBox
via the UserControl
.
Somewhere in your UserControl.xaml.cs:
public ListBox MyListBox
{
get
{
return {yourListBoxName};
}
}
Then when you instantiated your new UserControl
:
ElementHost elhost = new ElementHost();
elhost.Size = new Size(110, 60);
elhost.Location = new Point(45,35);
MyWPFControl wpfctl = new MyWPFControl();
elhost.Child = wpfctl;
this.Controls.Add(elhost);
//Access your ListBox via wpfctl.MyListBox
Alternatively you can have a look at MVVM and bind your ListBox.ListBoxItem
to your TextBox
;