public void LoadSettings(IAppConfiguration configs) { foreach (var item in this.Items) { if (this.ItemContainerGenerator.ContainerFromItem(item) is DependencyObject container) { var dataContext = container.GetValue(DataContextProperty); if (dataContext != null && configs.TryGetValue <bool>(typeof(BrowserItemsControl), dataContext.GetType(), nameof(ModernExpander.IsExpanded), out var isExpanded) == true) { SetIsExpanded(container, isExpanded); } } } }