George
George

Reputation: 195

Xamarin XAML error on Master-Detail Page when passing a parameter to a detail view constructor

When I want to pass a parameter to the view constructor I am getting an error in the MasterDetailPage xaml. Error: No constructors found for Xamarin.Forms.NavigationPage with matching x:Arguments.

MasterDetailPage:

    <MasterDetailPage.Master>
    <pages:LoginMasterDetailPageMaster x:Name="MasterPage" />
  </MasterDetailPage.Master>
  <MasterDetailPage.Detail>
    <NavigationPage>
      <x:Arguments>
         <pages:LoginView/>
      </x:Arguments>
    </NavigationPage>
  </MasterDetailPage.Detail>
</MasterDetailPage>

LoginView:

    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class LoginView : ContentPage
    {
        public LoginView(bool showAutoLogOutMessage)
        {
            InitializeComponent();
            BindingContext = ((ViewModelLocator)Application.Current.Resources["Locator"]).Login;
        }

Does anyone know how to solve this issues? Many thanks in advance.

Upvotes: 2

Views: 2167

Answers (1)

Nick Kovalsky
Nick Kovalsky

Reputation: 6472

Delete from xaml page

<MasterDetailPage.Detail>
    <NavigationPage>
      <x:Arguments>
         <pages:LoginView/>
      </x:Arguments>
    </NavigationPage>
  </MasterDetailPage.Detail>

Set in code behind, whatever you want by

Detail = new LoginView(paramshere);

or maybe later

Detail = new NavigationPage(new LoginView(paramshere));

Upvotes: 1

Related Questions