Can anyone help me figure out a way to retreive the content of a tab header in WPF?
All I want is the text in the header so I can assign it to some other variable, but there doesn't seem to be any way of getting at it.
I am very new to WPF.. but the last hour or so googling this problem has not returned anything helpful.
Thanks
You know how casting and such works, right?
<TabControl>
<TabItem Name="_tabItem1" Header="MyHeader"/>
</TabControl>
//Header is an object and hence needs to be casted for retrieval as string
string headerText = (string)_tabItem1.Header;
MessageBox.Show(headerText);
TabItem.Header
can be anything, even complex controls so if you did not set this to a string yourself you cannot retrieve it as string like this either.