@@ -257,23 +257,24 @@ public ICollectionView ProfileFiles
257257 }
258258 }
259259
260- private ProfileFileInfo _selectedProfileFile ;
260+ private ProfileFileInfo _selectedProfileFile = null ;
261261 public ProfileFileInfo SelectedProfileFile
262262 {
263263 get => _selectedProfileFile ;
264264 set
265265 {
266- if ( value == _selectedProfileFile || ( value != null && value . Equals ( _selectedProfileFile ) ) )
266+ if ( _isProfileLoading || ( value != null && value . Equals ( _selectedProfileFile ) ) )
267267 return ;
268268
269269 _selectedProfileFile = value ;
270270
271- if ( ! _isProfileLoading && value != null && ! value . Equals ( ProfileManager . LoadedProfileFile ) )
271+ // Switch profile...
272+ if ( value != null && ! value . Equals ( ProfileManager . LoadedProfileFile ) )
272273 {
273274 ProfileManager . SwitchProfile ( value ) ;
274275 SettingsManager . Current . Profiles_LastSelected = value . Name ;
275276 }
276-
277+
277278 OnPropertyChanged ( ) ;
278279 }
279280 }
@@ -368,19 +369,16 @@ private void AfterContentRendered()
368369
369370 // Load profiles
370371 _isProfileLoading = true ;
371-
372372 ProfileFiles = new CollectionViewSource { Source = ProfileManager . ProfileFiles } . View ;
373373 ProfileFiles . SortDescriptions . Add ( new SortDescription ( nameof ( ProfileFileInfo . Name ) , ListSortDirection . Ascending ) ) ;
374374 ProfileManager . OnProfileFileChangedEvent += ProfileManager_OnProfileFileChangedEvent ;
375-
376375 _isProfileLoading = false ;
377376
377+ // Switch profile
378378 SelectedProfileFile = ProfileFiles . SourceCollection . Cast < ProfileFileInfo > ( ) . FirstOrDefault ( x => x . Name == SettingsManager . Current . Profiles_LastSelected ) ;
379379
380- /*
381380 if ( SelectedProfileFile == null )
382381 SelectedProfileFile = ProfileFiles . SourceCollection . Cast < ProfileFileInfo > ( ) . FirstOrDefault ( ) ;
383- */
384382
385383 // Hide to tray after the window shows up... not nice, but otherwise the hotkeys do not work
386384 if ( CommandLineManager . Current . Autostart && SettingsManager . Current . Autostart_StartMinimizedInTray )
0 commit comments