How to select a TabItem based off of it's Header
In my program I have a tabItem that gets selected when a TreeViewItem with
an equivalent header is selected.
This is what I currently have (It works):
(parent_TreeViewItem.Items.Contains(SelectedItem))
{
tabControl1.SelectedItem = tabControl1.Items //Changes tab
according to TreeView
.OfType<TabItem>().SingleOrDefault(n =>
n.Header.ToString() == SelectedItem.Header.ToString());
}
The difference with what I'm doing this time is that the tabItem's header
that I'm selecting is composed of a string and an integer.
For example: The TreeViewItem selected will always have a header named
"Arrival", but the tabItem's header will have a form like "Arrival" +
integer. The integer value will come from the parent node's header.
For this process I'm thinking that I'll first need to get the header value
of the parent node, since it contains that integer value I need. Then I'll
need to modify my code above in someway to query for a node with a header
like, "Arrival" + parentHeader.
How would I do something like this?
Thank you.
No comments:
Post a Comment