I am having a weird issue, Xamarin Forms App works fine when I setup Content page as a startup page. If I set TabbedPage as a startup and same ContentPage as a Children of a TabbedPage then it doesn't display/data-bind ContentPage. No errors. What am I missing any idea? Here is my TabbedPage view model.
using MvvmCross.Core.ViewModels;
using System.Windows.Input;
namespace Company.Mobile.ViewModels
{
public class TabbedMainViewModel
: MvxViewModel
{
}
}
XAML:
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:forms="using:Xamarin.Forms"
xmlns:local="clr-namespace:company.Mobile.Pages;assembly=company.Mobile"
x:Class="company.Mobile.Pages.TabbedMainPage"
Title="Title">
<TabbedPage.Children>
<local:HomePage/>
<local:MainPage/>
<local:ResourcesPage/>
<local:ContactPage/>
</TabbedPage.Children>
</TabbedPage>
After a lot of trial and error and help from the community, here is what worked.
Set BindingContext to the ContentPage code-behind C#, something like below:
Get your data in HomeViewModel constructor something like below:
I would say that you can do that easier by adding this inline property for an each your tabbed page in XAML, e.g. for the home page it should be
BindingContext="{Binding HomePageViewModel}"