First of all, the solution I gave you last time works fine if the PanelBar is populated with data declaratively.
In case it is databound to a collection of data items, it is more appropriate to use the SelectedContainer property of the RadPanelBar:
sender, Telerik.Windows.RadRoutedEventArgs e)
e.Handled = e.OriginalSource == (sender
Using a comparison of strings requires perfectly overriden ToString()
method of the DataItems - if two items are different , their ToString()
methods should return different values. If this requirement is not fulfilled invoking of PreviewCollapsed
may never stop and then StackOverflow
Using the method ChildrenOfType<RadPanelBarItem>()
requires all the containers of the PaneBar
to be generated. This means you may had called this method before the generation of the containers was finished. However, a better practice in implementing your scenario is to add a property Expanded
to your DataItem
class and bind it to RadPanelBarItem
`s property IsExpanded.
I prepared a sample project for you demonstrating how to bind IsExpanded
Please take a look at it and let me know if it satisfies you.
Feel free to ask if you need further help.
All the best,
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking
system and vote to affect the priority of the items