File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Rubberduck.Core/UI/Controls Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -44,15 +44,19 @@ protected override void OnAttached()
4444 {
4545 base . OnAttached ( ) ;
4646
47- var states = GetExpandedStateStore ( ) ;
48- var expanded = ! states . ContainsKey ( GroupName ?? string . Empty ) ? ( bool ? ) null : states [ GroupName ?? string . Empty ] ;
47+ // Ensure the visual tree is fully loaded before trying to access parents
48+ AssociatedObject . Dispatcher . InvokeAsync ( ( ) => {
49+ var states = GetExpandedStateStore ( ) ;
50+ var expanded = ! states . ContainsKey ( GroupName ?? string . Empty ) ? ( bool ? ) null : states [ GroupName ?? string . Empty ] ;
4951
50- AssociatedObject . IsExpanded = expanded ?? InitialExpandedState ;
52+ AssociatedObject . IsExpanded = expanded ?? InitialExpandedState ;
5153
52- AssociatedObject . Expanded += OnExpanded ;
53- AssociatedObject . Collapsed += OnCollapsed ;
54+ AssociatedObject . Expanded += OnExpanded ;
55+ AssociatedObject . Collapsed += OnCollapsed ;
56+ } ) ;
5457 }
5558
59+
5660 protected override void OnDetaching ( )
5761 {
5862 AssociatedObject . Expanded -= OnExpanded ;
You can’t perform that action at this time.
0 commit comments