private static void OnModeChangeLayouts(ModeChangedArgs args) { // Prevent double loading the default/last layout already done by the WindowLayout system. if (args.prevIndex == -1) { return; } if (!HasCapability(ModeCapability.LayoutSwitching, true)) { return; } WindowLayout.SaveCurrentLayoutPerMode(GetModeId(args.prevIndex)); try { // Load the last valid layout for this mode WindowLayout.LoadDefaultWindowPreferences(); } catch (Exception) { // Error while loading layout. Load the default layout for current mode. WindowLayout.LoadDefaultLayout(); } WindowLayout.ReloadWindowLayoutMenu(); }