带有 ReactiveUI 的 Xamarin Forms - 对 xaml.g.cs 的更改丢失,由 ReactiveUI 错误引起
Xamarin Forms with ReactiveUI - Changes to xaml.g.cs is lost, causes by ReactiveUI bug
我有一个基于标签页结构的 Xamarin 表单应用程序。 tabbedpageview 视图不是从 tabbedpage 继承的,而是像这样从 ReactiveTabbedPage 继承的:
public partial class PlanningDetailPage : ReactiveTabbedPage<PlanningDetailViewModel>
执行此操作时,xaml.g.cs 文件出现错误:
Using a generic type EactiveTabbedPage<TViewModel> requires 1 type arguments
见下图:
当我将其更改为:
public partial class PlanningDetailPage : global::ReactiveUI.XamForms.ReactiveTabbedPage<PlanningDetailViewModel> {
更改会在一段时间后丢失。为什么会这样,我该如何解决这个问题?
如果你的页面是 ReactiveTabbedPage 的子类,你需要定义它的 ViewModel ,比如
using ReactiveUI.XamForms;
using ReactiveUI;
public partial class TabbedPage1 : ReactiveTabbedPage<MainViewModel>
{
public TabbedPage1()
{
InitializeComponent();
this.ViewModel = new MainViewModel();
}
}
public class MainViewModel : ReactiveObject
{
//...
}
在xaml
<?xml version="1.0" encoding="utf-8" ?>
<rxui:ReactiveTabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:rxui="clr-namespace:ReactiveUI.XamForms;assembly=ReactiveUI.XamForms" xmlns:local="clr-namespace:App24"
mc:Ignorable="d"
x:Class="App24.TabbedPage1"
x:TypeArguments="local:MainViewModel">
<!--Pages can be added as references or inline-->
</rxui:ReactiveTabbedPage>
我有一个基于标签页结构的 Xamarin 表单应用程序。 tabbedpageview 视图不是从 tabbedpage 继承的,而是像这样从 ReactiveTabbedPage 继承的:
public partial class PlanningDetailPage : ReactiveTabbedPage<PlanningDetailViewModel>
执行此操作时,xaml.g.cs 文件出现错误:
Using a generic type EactiveTabbedPage<TViewModel> requires 1 type arguments
见下图:
当我将其更改为:
public partial class PlanningDetailPage : global::ReactiveUI.XamForms.ReactiveTabbedPage<PlanningDetailViewModel> {
更改会在一段时间后丢失。为什么会这样,我该如何解决这个问题?
如果你的页面是 ReactiveTabbedPage 的子类,你需要定义它的 ViewModel ,比如
using ReactiveUI.XamForms;
using ReactiveUI;
public partial class TabbedPage1 : ReactiveTabbedPage<MainViewModel>
{
public TabbedPage1()
{
InitializeComponent();
this.ViewModel = new MainViewModel();
}
}
public class MainViewModel : ReactiveObject
{
//...
}
在xaml
<?xml version="1.0" encoding="utf-8" ?>
<rxui:ReactiveTabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:rxui="clr-namespace:ReactiveUI.XamForms;assembly=ReactiveUI.XamForms" xmlns:local="clr-namespace:App24"
mc:Ignorable="d"
x:Class="App24.TabbedPage1"
x:TypeArguments="local:MainViewModel">
<!--Pages can be added as references or inline-->
</rxui:ReactiveTabbedPage>