File tree 1 file changed +9
-5
lines changed
Rubberduck.Core/UI/Controls
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()
44
44
{
45
45
base . OnAttached ( ) ;
46
46
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 ] ;
49
51
50
- AssociatedObject . IsExpanded = expanded ?? InitialExpandedState ;
52
+ AssociatedObject . IsExpanded = expanded ?? InitialExpandedState ;
51
53
52
- AssociatedObject . Expanded += OnExpanded ;
53
- AssociatedObject . Collapsed += OnCollapsed ;
54
+ AssociatedObject . Expanded += OnExpanded ;
55
+ AssociatedObject . Collapsed += OnCollapsed ;
56
+ } ) ;
54
57
}
55
58
59
+
56
60
protected override void OnDetaching ( )
57
61
{
58
62
AssociatedObject . Expanded -= OnExpanded ;
You can’t perform that action at this time.
0 commit comments