In previous versions of the TableOfContents control the treeview was collapsed by default. Now in 100.7.1 it is expanded by default. We have a large number of layers and this is not acceptable to the users.
Current default:
I tried to see if I could close them when the TableOfContents is loaded by setting IsExpanded on the item to false, but this did not take
foreach (var item in TableOfContents.ItemsSource)
{
if ( item is TocItem tocItem )
{
tocItem.IsExpanded = false;
}
}
How can I get these to be collapsed when the TableOfContents initially
Thanks
-Joe
Solved! Go to Solution.
I did find a solution that works by setting the IsExpanded when the item is added to the collection. The following was added in the views code behind constructor
var collection = TableOfContents.ItemsSource as INotifyCollectionChanged;
if ( collection == null ) return;
collection.CollectionChanged += (sender, args) =>
{
if ( args.NewItems == null ) return;
foreach (var item in args.NewItems)
{
if ( item is TocItem tocItem )
{
tocItem.IsExpanded = false;
}
}
};
I did find a solution that works by setting the IsExpanded when the item is added to the collection. The following was added in the views code behind constructor
var collection = TableOfContents.ItemsSource as INotifyCollectionChanged;
if ( collection == null ) return;
collection.CollectionChanged += (sender, args) =>
{
if ( args.NewItems == null ) return;
foreach (var item in args.NewItems)
{
if ( item is TocItem tocItem )
{
tocItem.IsExpanded = false;
}
}
};