How to change the way FreshMvvm expects the page name for an entity?

I have a simple project built on FreshMvvm and there is only one entity, Contact with 2 string properties, Name and Number.

The application shows a list of contacts and when a user taps on a contact, it opens the ContactPage.xaml with the contact details.

The application works ok, but I would like to change the name of ContactPage.xaml, to ContactDetailsPage.xaml and in this case when FreshMvvm tries to find ContactPage.xaml upon opening contact details, it fails.

How can I tell to FreshMvvm to seek for ContactDetailsPage.xaml instead of ContactPage.xaml?

ContactListPage.xaml looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="placeholder here"
             xmlns:x="another placeholder here, because this forum does not allow to post links for new users"
             x:Class="FreshMvvmDemo.Pages.ContactListPage">
    <ContentPage.Content>
        <StackLayout>
            <Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
            <ListView ItemsSource="{Binding ContactList}" SelectedItem="{Binding SelectedContact}">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <TextCell Text="{Binding Name}" Detail="{Binding Number}"></TextCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

ContactPage.xaml looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="placeholder here"
             xmlns:x="another placeholder here, because this forum does not allow to post links for new users"
             x:Class="FreshMvvmDemo.Pages.ContactPage">
    <ContentPage.Content>
        <StackLayout>
            <Entry Text="{Binding Contact.Name}"></Entry>
            <Entry Text="{Binding Contact.Number}"></Entry>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>
Tagged:

Best Answer

  • Accepted Answer

    To open ContactDetailsPage.xaml instead of ContactPage.xaml I have to rename corresponding ViewModel class from ContactPageModel to ContactDetailsPageModel.

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    Sorry, I couldn't fully understand the meaning of How can I tell to FreshMvvm to seek for ContactDetailsPage.xaml instead of ContactPage.xaml?

  • Rafael_OsipovRafael_Osipov Member
    Accepted Answer

    To open ContactDetailsPage.xaml instead of ContactPage.xaml I have to rename corresponding ViewModel class from ContactPageModel to ContactDetailsPageModel.

  • Rafael_OsipovRafael_Osipov Member

    @jezh Thank you for your help. I wanted to force FreshMvvm to use another xaml page name. It opened ContactPage.xaml but I wanted to open page with another name. The solution was in renaming the corresponding ViewModel class.

  • jezhjezh Member, Xamarin Team Xamurai

    Congrats, and thanks for sharing the solution.

Sign In or Register to comment.