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()
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 . BeginInvoke ( new System . Action ( ( ) =>
49
+ {
50
+ var states = GetExpandedStateStore ( ) ;
51
+ var expanded = ! states . ContainsKey ( GroupName ?? string . Empty ) ? ( bool ? ) null : states [ GroupName ?? string . Empty ] ;
49
52
50
- AssociatedObject . IsExpanded = expanded ?? InitialExpandedState ;
53
+ AssociatedObject . IsExpanded = expanded ?? InitialExpandedState ;
51
54
52
- AssociatedObject . Expanded += OnExpanded ;
53
- AssociatedObject . Collapsed += OnCollapsed ;
55
+ AssociatedObject . Expanded += OnExpanded ;
56
+ AssociatedObject . Collapsed += OnCollapsed ;
57
+ } ) ) ;
54
58
}
55
59
60
+
56
61
protected override void OnDetaching ( )
57
62
{
58
63
AssociatedObject . Expanded -= OnExpanded ;
You can’t perform that action at this time.
0 commit comments