【问题标题】:Xamarin Forms with ReactiveUI - Changes to xaml.g.cs is lost, causes by ReactiveUI bug具有 ReactiveUI 的 Xamarin 表单 - 对 xaml.g.cs 的更改丢失,由 ReactiveUI 错误引起
【发布时间】:2020-04-20 09:09:44
【问题描述】:

我有一个基于标签页结构的 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> {

更改会在一段时间后丢失。为什么会这样,我该如何解决这个问题?

【问题讨论】:

    标签: xamarin.forms reactiveui tabbedpage


    【解决方案1】:

    如果您的 Page 是 ReactiveTabbedPage 的子类,则需要定义它的 ViewModel,如

    using ReactiveUI.XamForms;
    using ReactiveUI;
    
    public partial class TabbedPage1 : ReactiveTabbedPage<MainViewModel>
    {
        public TabbedPage1()
        {
            InitializeComponent();
    
            this.ViewModel = new MainViewModel();
    
        }
    }
    
    public class MainViewModel : ReactiveObject
    {
        //...
    }
    

    在xml中

    <?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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多