Reputation: 957
I have a Xamarin forms application based on the tabbedpage structure. The tabbedpageview view doesn't inherit from tabbedpage but it inherits from ReactiveTabbedPage like this:
public partial class PlanningDetailPage : ReactiveTabbedPage<PlanningDetailViewModel>
When doing that, the xaml.g.cs file gives an error:
Using a generic type EactiveTabbedPage<TViewModel> requires 1 type arguments
See image below:
When I change that to this:
public partial class PlanningDetailPage : global::ReactiveUI.XamForms.ReactiveTabbedPage<PlanningDetailViewModel> {
The changes are lost after some time. Why is that, and how can I fix this issue?
Upvotes: 1
Views: 146
Reputation: 18861
If your Page is a subclass of ReactiveTabbedPage , you need to define the ViewModel of it ,like
using ReactiveUI.XamForms;
using ReactiveUI;
public partial class TabbedPage1 : ReactiveTabbedPage<MainViewModel>
{
public TabbedPage1()
{
InitializeComponent();
this.ViewModel = new MainViewModel();
}
}
public class MainViewModel : ReactiveObject
{
//...
}
<?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>
Upvotes: 3