File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Rubberduck.Core/UI/Controls Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -44,15 +44,20 @@ 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 . BeginInvoke ( new System . Action ( ( ) =>
49+ {
50+ var states = GetExpandedStateStore ( ) ;
51+ var expanded = ! states . ContainsKey ( GroupName ?? string . Empty ) ? ( bool ? ) null : states [ GroupName ?? string . Empty ] ;
4952
50- AssociatedObject . IsExpanded = expanded ?? InitialExpandedState ;
53+ AssociatedObject . IsExpanded = expanded ?? InitialExpandedState ;
5154
52- AssociatedObject . Expanded += OnExpanded ;
53- AssociatedObject . Collapsed += OnCollapsed ;
55+ AssociatedObject . Expanded += OnExpanded ;
56+ AssociatedObject . Collapsed += OnCollapsed ;
57+ } ) ) ;
5458 }
5559
60+
5661 protected override void OnDetaching ( )
5762 {
5863 AssociatedObject . Expanded -= OnExpanded ;
You can’t perform that action at this time.
0 commit comments