I am trying to implement a xamarin app that will have a MainPage like a container that will host the rest of my pages(as content view?).
MainPage.xaml
<ContentPage 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:views="clr-namespace:TalosLib"
mc:Ignorable="d"
x:Class="TalosLib.MainPage">
<ContentPage.Content>
<StackLayout >
<StackLayout.Resources>
<DataTemplate x:Key="login">
<views:LoginPage />
</DataTemplate>
</StackLayout.Resources>
<ContentView Content="{Binding CurrentView}" ControlTemplate="{StaticResource login}"/>
<!--<CollectionView ItemsSource="{Binding CurrentView}" ItemTemplate="{StaticResource login}"/>-->
</StackLayout>
</ContentPage.Content>
MainPageModel.cs
public class MainPageModel : FreshBasePageModel
{
//private ObservableCollection<LoginPageModel> _currentView;
//public ObservableCollection<LoginPageModel> CurrentView
//{
// get { return _currentView; }
// set { _currentView = value; RaisePropertyChanged("CurrentView"); }
//}
private LoginPageModel _currentView;
public LoginPageModel CurrentView
{
get { return _currentView; }
set { _currentView = value; RaisePropertyChanged("CurrentView"); }
}
public override void Init(object initData)
{
base.Init(initData);
//CurrentView = new ObservableCollection<LoginPageModel>();
//CurrentView.Add(new LoginPageModel());
CurrentView = new LoginPageModel();
RaisePropertyChanged(nameof(CurrentView));
}
}
Right now i am trying just to show the LoginPage but it doesn't appear. I managed to make it work if i used the commented parts of the code. i am using FreshMVVM. Any thoughts?