I would like to synchronize two object headers with pointers.
For example: I know I can’t do this with the current syntax, but I would like something like:
Node node = new Node();
node.Label = "header1";
TabItem tabItem = new TabItem;
*(tabItem.Header) = &(node.Label);
So whenever I change node.Label, tabItem.Header changes as well.
Edit: added an example
You should be able to accomplish this using databinding. If Node is a custom object, you will want to either suport INotifyPropertyChange, or implement the Label property as a dependency property. (I’m not sure what the convention is, I would guess that if Node is intrinsically a UI object, then use a dependency property, and if it’s not then implement INotifyPropertyChanged.
Example:
The Node object:
The code behind your form (this method sets up your databinding in code, you could also set up the databinding in the XAML):
The XAML for your form
When you databind, WPF will detect that your Node object implements INotifyPropertyChanged, and it will subscribe the PropertyChanged event automatically.
(notice that in the MainWindow code, I set the binding and then I set the value of the Node.Label — the tab header detects it and updates).