mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-27 04:41:15 +08:00
更换page页切换逻辑
This commit is contained in:
@@ -68,7 +68,7 @@
|
||||
|
||||
<ui:NavigationView.Content>
|
||||
<ui:Frame x:Name="frame" DataContext="{Binding SelectedItem}" Margin="-10 0 0 0">
|
||||
<ui:Frame.DataTemplates>
|
||||
<!--<ui:Frame.DataTemplates>
|
||||
<DataTemplate DataType="vm:ProxyScriptManagePageViewModel">
|
||||
<pages:ProxyScriptManagePage/>
|
||||
</DataTemplate>
|
||||
@@ -102,7 +102,7 @@
|
||||
<DataTemplate DataType="vm:ArchiSteamFarmPlusPageViewModel">
|
||||
<pages:ArchiSteamFarmPlusPage/>
|
||||
</DataTemplate>
|
||||
</ui:Frame.DataTemplates>
|
||||
</ui:Frame.DataTemplates>-->
|
||||
</ui:Frame>
|
||||
</ui:NavigationView.Content>
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Markup.Xaml.Templates;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.ReactiveUI;
|
||||
@@ -13,8 +11,8 @@ using System.Application.Settings;
|
||||
using System.Application.UI.ViewModels;
|
||||
using System.Application.UI.Views.Controls;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.Application.UI.Views.Pages;
|
||||
|
||||
namespace System.Application.UI.Views
|
||||
{
|
||||
@@ -22,6 +20,26 @@ namespace System.Application.UI.Views
|
||||
{
|
||||
private readonly IBrush? _backgroundTemp;
|
||||
|
||||
private static IReadOnlyDictionary<Type, Type> PageTypes { get; }
|
||||
|
||||
static MainView()
|
||||
{
|
||||
PageTypes = new Dictionary<Type, Type>
|
||||
{
|
||||
{ typeof(ProxyScriptManagePageViewModel), typeof(ProxyScriptManagePage) },
|
||||
{ typeof(StartPageViewModel), typeof(StartPage) },
|
||||
{ typeof(SteamAccountPageViewModel), typeof(SteamAccountPage) },
|
||||
{ typeof(SettingsPageViewModel), typeof(SettingsPage) },
|
||||
{ typeof(AboutPageViewModel), typeof(AboutPage) },
|
||||
{ typeof(DebugPageViewModel), typeof(DebugPage) },
|
||||
{ typeof(GameListPageViewModel), typeof(GameListPage) },
|
||||
{ typeof(CommunityProxyPageViewModel), typeof(CommunityProxyPage) },
|
||||
{ typeof(LocalAuthPageViewModel), typeof(LocalAuthPage) },
|
||||
{ typeof(GameRelatedPageViewModel), typeof(GameRelatedPage) },
|
||||
{ typeof(ArchiSteamFarmPlusPageViewModel), typeof(ArchiSteamFarmPlusPage) },
|
||||
};
|
||||
}
|
||||
|
||||
public MainView()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -88,11 +106,12 @@ namespace System.Application.UI.Views
|
||||
{
|
||||
if (x != null)
|
||||
{
|
||||
var page = frame.DataTemplates.FirstOrDefault(f => f.Match(x));
|
||||
if (page is DataTemplate template)
|
||||
{
|
||||
frame.Navigate(template.Build(null).GetType());
|
||||
}
|
||||
//var page = frame.DataTemplates.FirstOrDefault(f => f.Match(x));
|
||||
//if (page is DataTemplate template)
|
||||
//{
|
||||
// frame.Navigate(template.Build(null).GetType());
|
||||
//}
|
||||
frame.Navigate(PageTypes[x.GetType()]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user