@@ -82,7 +82,7 @@ protected override void OnApplyTemplate()
8282 // mode.ContentOnInactive = DefaultInactiveMode;
8383 }
8484
85- _modesHostGrid . SizeChanged += _modesHostGrid_SizeChanged ;
85+ _modesHostGrid . SizeChanged += ModesHostGrid_SizeChanged ;
8686
8787 GotFocus += Omnibar_GotFocus ;
8888 LostFocus += Omnibar_LostFocus ;
@@ -94,7 +94,7 @@ protected override void OnApplyTemplate()
9494
9595 // Methods
9696
97- internal void ChangeExpandedMode ( OmnibarMode modeToExpand )
97+ internal void ChangeMode ( OmnibarMode modeToExpand )
9898 {
9999 if ( _modesHostGrid is null || Modes is null )
100100 throw new NullReferenceException ( ) ;
@@ -103,15 +103,15 @@ internal void ChangeExpandedMode(OmnibarMode modeToExpand)
103103 foreach ( var column in _modesHostGrid . ColumnDefinitions )
104104 column . Width = GridLength . Auto ;
105105 foreach ( var mode in Modes )
106- {
107106 VisualStateManager . GoToState ( mode , "Unfocused" , true ) ;
108- }
109107
110108 // Expand the given mode
111109 VisualStateManager . GoToState ( modeToExpand , "Focused" , true ) ;
112110 _modesHostGrid . ColumnDefinitions [ _modesHostGrid . Children . IndexOf ( modeToExpand ) ] . Width = new ( 1 , GridUnitType . Star ) ;
113111
114112 CurrentActiveMode = modeToExpand ;
113+
114+ UpdateVisualStates ( ) ;
115115 }
116116
117117 private void UpdateVisualStates ( )
@@ -121,13 +121,16 @@ private void UpdateVisualStates()
121121 _isFocused ? "Focused" : "Normal" ,
122122 true ) ;
123123
124+ if ( CurrentActiveMode is not null && _autoSuggestPopup is not null )
125+ VisualStateManager . GoToState ( this , _isFocused && CurrentActiveMode . SuggestionItemsSource is not null ? "PopupOpened" : "PopupClosed" , true ) ;
126+
124127 if ( CurrentActiveMode is not null )
125128 VisualStateManager . GoToState ( CurrentActiveMode , _isFocused ? "Focused" : "CurrentUnfocused" , true ) ;
126129 }
127130
128131 // Events
129132
130- private void _modesHostGrid_SizeChanged ( object sender , SizeChangedEventArgs e )
133+ private void ModesHostGrid_SizeChanged ( object sender , SizeChangedEventArgs e )
131134 {
132135 _autoSuggestBoxBorder ! . Width = _modesHostGrid ! . ActualWidth ;
133136 }
@@ -136,16 +139,12 @@ private void Omnibar_GotFocus(object sender, RoutedEventArgs e)
136139 {
137140 _isFocused = true ;
138141 UpdateVisualStates ( ) ;
139-
140- _autoSuggestPopup ! . IsOpen = true ;
141142 }
142143
143144 private void Omnibar_LostFocus ( object sender , RoutedEventArgs e )
144145 {
145146 _isFocused = false ;
146147 UpdateVisualStates ( ) ;
147-
148- _autoSuggestPopup ! . IsOpen = false ;
149148 }
150149 }
151150}
0 commit comments