mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-15 17:05:03 +03:00
Reset tab content when switching layouts
Clear all auxiliary tab contents before applying a new grid orientation to prevent stale view reuse, and remove the delayed tab-index workaround. Also treat `ProfilesViewModel` as a transient view so its view is recreated like other dynamic tabs.
This commit is contained in:
@@ -70,7 +70,8 @@ public class SimpleViewLocator : IDataTemplate
|
|||||||
{
|
{
|
||||||
return vmType == typeof(MsgViewModel)
|
return vmType == typeof(MsgViewModel)
|
||||||
|| vmType == typeof(ClashProxiesViewModel)
|
|| vmType == typeof(ClashProxiesViewModel)
|
||||||
|| vmType == typeof(ClashConnectionsViewModel);
|
|| vmType == typeof(ClashConnectionsViewModel)
|
||||||
|
|| vmType == typeof(ProfilesViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Control CreateView(Func<Control?> factory, Type vmType)
|
private static Control CreateView(Func<Control?> factory, Type vmType)
|
||||||
|
|||||||
@@ -405,6 +405,8 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||||||
var currentLayoutDisposables = new MultipleDisposable();
|
var currentLayoutDisposables = new MultipleDisposable();
|
||||||
_layoutBindingsDisposable.Create(currentLayoutDisposables);
|
_layoutBindingsDisposable.Create(currentLayoutDisposables);
|
||||||
|
|
||||||
|
ClearLayoutContent();
|
||||||
|
|
||||||
gridMain.IsVisible = orientation == EGirdOrientation.Horizontal;
|
gridMain.IsVisible = orientation == EGirdOrientation.Horizontal;
|
||||||
gridMain1.IsVisible = orientation == EGirdOrientation.Vertical;
|
gridMain1.IsVisible = orientation == EGirdOrientation.Vertical;
|
||||||
gridMain2.IsVisible = orientation == EGirdOrientation.Tab;
|
gridMain2.IsVisible = orientation == EGirdOrientation.Tab;
|
||||||
@@ -445,22 +447,40 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// workaround
|
//// workaround
|
||||||
Task.Run(async () =>
|
//Task.Run(async () =>
|
||||||
{
|
//{
|
||||||
await Task.Delay(5000);
|
// await Task.Delay(5000);
|
||||||
Dispatcher.UIThread.Post(() =>
|
// Dispatcher.UIThread.Post(() =>
|
||||||
{
|
// {
|
||||||
ViewModel?.TabMainSelectedIndex = 0;
|
// ViewModel?.TabMainSelectedIndex = 0;
|
||||||
tabMain.SelectedIndex = 0;
|
// tabMain.SelectedIndex = 0;
|
||||||
tabMain1.SelectedIndex = 0;
|
// tabMain1.SelectedIndex = 0;
|
||||||
tabMain2.SelectedIndex = 0;
|
// tabMain2.SelectedIndex = 0;
|
||||||
});
|
// });
|
||||||
});
|
//});
|
||||||
|
|
||||||
RestoreUI();
|
RestoreUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ClearLayoutContent()
|
||||||
|
{
|
||||||
|
tabProfiles.Content = null;
|
||||||
|
tabMsgView.Content = null;
|
||||||
|
tabClashProxies.Content = null;
|
||||||
|
tabClashConnections.Content = null;
|
||||||
|
|
||||||
|
tabProfiles1.Content = null;
|
||||||
|
tabMsgView1.Content = null;
|
||||||
|
tabClashProxies1.Content = null;
|
||||||
|
tabClashConnections1.Content = null;
|
||||||
|
|
||||||
|
tabProfiles2.Content = null;
|
||||||
|
tabMsgView2.Content = null;
|
||||||
|
tabClashProxies2.Content = null;
|
||||||
|
tabClashConnections2.Content = null;
|
||||||
|
}
|
||||||
|
|
||||||
private void AddHelpMenuItem()
|
private void AddHelpMenuItem()
|
||||||
{
|
{
|
||||||
var coreInfo = CoreInfoManager.Instance.GetCoreInfo();
|
var coreInfo = CoreInfoManager.Instance.GetCoreInfo();
|
||||||
|
|||||||
Reference in New Issue
Block a user