I was wondering how could I use a custom object in more than one panel.
I made a panelModified object (extends from Panel) and want to place it in two normal panels, so when the object change its status, both panels display the updated information.
In my case the “panelModified” is a panel with some Buttons and an embeded video in it.
Here is the code:
panelPreview = new PanelPreview(file); (panelModified object)
panel1.Controls.Add(panelPreview);
panel2.Controls.Add(panelPreview);
it only shows in the panel2 🙁
Your custom object that you’re showing has to be able to notify that it’s values are changing (ie implements INotifyPropertyChanged).
Then, you can change your PanelPreview to bind on your object.
This way, you can have as much instances as you like – when you change in one instance, the INotifyPropertyChanged will trigger the displaying on all others.
For example:
And then in your binding place you bind to it. Here I’m binding to textboxes, but you could do it with whatever: