初步UI模板交互

This commit is contained in:
muqing 2024-07-15 13:22:53 +08:00
parent 055b30c932
commit 5022ed0165
14 changed files with 165 additions and 42 deletions

View File

@ -22,7 +22,7 @@ public class DefaultActivationHandler : ActivationHandler<LaunchActivatedEventAr
protected async override Task HandleInternalAsync(LaunchActivatedEventArgs args)
{
_navigationService.NavigateTo(typeof(MainViewModel).FullName!, args.Arguments);
_navigationService.NavigateTo(typeof(HomePageViewModel).FullName!, args.Arguments);
await Task.CompletedTask;
}

View File

@ -71,11 +71,17 @@ public partial class App : Application
// Views and ViewModels
services.AddTransient<SettingsViewModel>();
services.AddTransient<SettingsPage>();
services.AddTransient<MainViewModel>();
services.AddTransient<MainPage>();
//services.AddTransient<MainViewModel>();
//services.AddTransient<MainPage>();
services.AddTransient<HomePageViewModel>();
services.AddTransient<HomePage>();
services.AddTransient<ConcernViewModel>();
services.AddTransient<Concern>();
services.AddTransient<RankingViewModel>();
services.AddTransient<RankingPage>();
services.AddTransient<UserViewModel>();
services.AddTransient<UserPage>();
services.AddTransient<ShellPage>();
services.AddTransient<ShellViewModel>();

View File

@ -19,7 +19,10 @@
<DefaultLanguage>zh-cn</DefaultLanguage>
</PropertyGroup>
<ItemGroup>
<None Remove="Views\Concern.xaml" />
<None Remove="Views\HomePage.xaml" />
<None Remove="Views\RankingPage.xaml" />
<None Remove="Views\UserPage.xaml" />
</ItemGroup>
<ItemGroup>
@ -49,6 +52,15 @@
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<Page Update="Views\Concern.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Views\UserPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Views\RankingPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Views\HomePage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>

View File

@ -14,8 +14,13 @@ public class PageService : IPageService
public PageService()
{
Configure<MainViewModel, MainPage>();
//Configure<MainViewModel, MainPage>();
Configure<HomePageViewModel, HomePage>();
Configure<ConcernViewModel, Concern>();
Configure<RankingViewModel, RankingPage>();
Configure<UserViewModel, UserPage>();
Configure<SettingsViewModel, SettingsPage>();
}

View File

@ -1,10 +0,0 @@
using CommunityToolkit.Mvvm.ComponentModel;
namespace RustTools.ViewModels;
public partial class MainViewModel : ObservableRecipient
{
public MainViewModel()
{
}
}

View File

@ -1,13 +1,15 @@
<Page
x:Class="RustTools.Views.MainPage"
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="RustTools.Views.Concern"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:RustTools.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid x:Name="ContentArea">
<TextBlock x:Uid="Settings_Theme" />
<Grid>
</Grid>
</Page>

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using RustTools.ViewModels;
using Windows.Foundation;
using Windows.Foundation.Collections;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace RustTools.Views;
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class Concern : Page
{
public ConcernViewModel ConcernViewModel { get; set; }
public Concern()
{
ConcernViewModel = App.GetService<ConcernViewModel>();
InitializeComponent();
}
}

View File

@ -1,19 +0,0 @@
using Microsoft.UI.Xaml.Controls;
using RustTools.ViewModels;
namespace RustTools.Views;
public sealed partial class MainPage : Page
{
public MainViewModel ViewModel
{
get;
}
public MainPage()
{
ViewModel = App.GetService<MainViewModel>();
InitializeComponent();
}
}

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="RustTools.Views.RankingPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:RustTools.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
</Grid>
</Page>

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using RustTools.ViewModels;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace RustTools.Views;
public sealed partial class RankingPage : Page
{
public RankingViewModel ViewModel
{
get; set;
}
public RankingPage()
{
ViewModel=App.GetService<RankingViewModel>();
InitializeComponent();
}
}

View File

@ -47,15 +47,15 @@
Icon="Home" />
<NavigationViewItem
x:Uid="Concern"
helpers:NavigationHelper.NavigateTo="RustTools.ViewModels.MainViewModel"
helpers:NavigationHelper.NavigateTo="RustTools.ViewModels.ConcernViewModel"
Icon="Contact" />
<NavigationViewItem
x:Uid="Ranking"
helpers:NavigationHelper.NavigateTo="RustTools.ViewModels.MainViewModel"
helpers:NavigationHelper.NavigateTo="RustTools.ViewModels.RankingViewModel"
Icon="List" />
<NavigationViewItem
x:Uid="User"
helpers:NavigationHelper.NavigateTo="RustTools.ViewModels.MainViewModel"
helpers:NavigationHelper.NavigateTo="RustTools.ViewModels.UserViewModel"
Icon="Contact2" />
</NavigationView.MenuItems>
<NavigationView.HeaderTemplate>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Page
x:Class="RustTools.Views.UserPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:RustTools.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
</Grid>
</Page>

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using RustTools.ViewModels;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace RustTools.Views;
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class UserPage : Page
{
public UserViewModel UserViewModel { get; set; }
public UserPage()
{
UserViewModel=App.GetService<UserViewModel>();
InitializeComponent();
}
}