如何使用 Xamarin.Forms 和 MvvmCross 设置我的 UWP 项目
How to setup my UWP project with Xamarin.Forms and MvvmCross
我有一个使用 MvvmCross 的 Xamarin.Forms 解决方案。我有 Android 项目可以正常使用它。我想添加一个 UWP 项目以用于我的 Forms 项目,但我找不到任何关于如何使用我的 Forms 和 MvvmCross 设置创建 UWP 项目的文档。
MvvmCross Forms UWP Playground Project 帮助很大,对任何基础知识都非常有用。这是其他任何人想要的解决方案:
将App.xaml改为
<local:MyApp
x:Class="MyApp.UWP.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyApp.Forms.UWP"
RequestedTheme="Light">
</local:MyApp>
并且在 App.xaml.cs:
sealed partial class App
{
public App()
{
InitializeComponent();
}
}
public abstract class MyApp : MvxWindowsApplication<MvxFormsWindowsSetup<Core.App, Forms.App>, Core.App, Forms.App, MainPage>
{
}
和MainPage.xaml:
<mvxf:MvxFormsWindowsPage
xmlns:mvxf="using:MvvmCross.Forms.Platforms.Uap.Views"
x:Class="MyApp.Forms.UWP.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyApp.Forms.UWP"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
</Grid>
</mvxf:MvxFormsWindowsPage>
MainPage.xaml.cs
public sealed partial class MainPage
{
public MainPage()
{
this.InitializeComponent();
}
}
我有一个使用 MvvmCross 的 Xamarin.Forms 解决方案。我有 Android 项目可以正常使用它。我想添加一个 UWP 项目以用于我的 Forms 项目,但我找不到任何关于如何使用我的 Forms 和 MvvmCross 设置创建 UWP 项目的文档。
MvvmCross Forms UWP Playground Project 帮助很大,对任何基础知识都非常有用。这是其他任何人想要的解决方案:
将App.xaml改为
<local:MyApp
x:Class="MyApp.UWP.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyApp.Forms.UWP"
RequestedTheme="Light">
</local:MyApp>
并且在 App.xaml.cs:
sealed partial class App
{
public App()
{
InitializeComponent();
}
}
public abstract class MyApp : MvxWindowsApplication<MvxFormsWindowsSetup<Core.App, Forms.App>, Core.App, Forms.App, MainPage>
{
}
和MainPage.xaml:
<mvxf:MvxFormsWindowsPage
xmlns:mvxf="using:MvvmCross.Forms.Platforms.Uap.Views"
x:Class="MyApp.Forms.UWP.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyApp.Forms.UWP"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
</Grid>
</mvxf:MvxFormsWindowsPage>
MainPage.xaml.cs
public sealed partial class MainPage
{
public MainPage()
{
this.InitializeComponent();
}
}