Reputation: 163
This is my TabbedPage
code:
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MojLek.Views.OrdersPage"
xmlns:local="clr-namespace:MyProject.Views"
Title="Orders">
<!--Pages can be added as references or inline-->
<local:NewClaimPage IconImageSource="Add.png" />
</TabbedPage>
NewClaimPage
code:
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class NewClaimPage : ContentPage
{
NewClaimPageViewModel viewModel = new NewClaimPageViewModel();
public NewClaimPage()
{
InitializeComponent();
BindingContext = viewModel;
}
protected override void OnAppearing()
{
base.OnAppearing();
viewModel.LoadPatientDoctorsCommand.Execute(null);
}
}
OnAppearing
is not fired, NewClaim
ContentPage not fired, NewClaimViewModel
not fired. What is the problem?
Upvotes: 0
Views: 175
Reputation: 10938
Maybe you miss something in your viewmodel. Please check the suggestions below.
Solution1:
Due to i do not have the details for your viewmodel, I make a simple code for your reference. Set the data in your voewmodel:
public class NewClaimPageViewModel
{
public NewClaimPageViewModel()
{
str = "Hello";
}
public string str { get; set; }
}
Binding in your xaml: NewClaimPage
<ContentPage.Content>
<StackLayout>
<Label
HorizontalOptions="CenterAndExpand"
Text="NewClaimPage!"
VerticalOptions="CenterAndExpand" />
<Label Text="{Binding str}" />
</StackLayout>
</ContentPage.Content>
Solution2:
Or you could BindingContext in your NewClaimPage.
<ContentPage.BindingContext>
<vm:NewClaimPageViewModel />
</ContentPage.BindingContext>
Upvotes: 1