dotnet / dotnet/maui-samples

FlyOutPage Dependency Injection

Open
#252 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
3.7k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

Hi,

Trying to apply dependency injection while using FlyOutPage.

In the sample project FlyoutPageSample, I have added a simple class called MyViewModel and added it to the MainPage constructor :

`public MainPage(MyViewModel mv)
{
InitializeComponent();
}`

The app will not compile and throws the following error :

Build started...
1>------ Build started: Project: FlyoutPageSample, Configuration: Debug Any CPU ------
1>AppFlyout.xaml(11,18): XamlC error XFC0004: Missing default constructor for "FlyoutPageSample.MainPage".
1>Done building project "FlyoutPageSample.csproj" -- FAILED.
1>AppFlyout.xaml(11,18): XamlC error XFC0004: Missing default constructor for "FlyoutPageSample.MainPage".
1>AppFlyout.xaml(11,18): XamlC error XFC0004: Missing default constructor for "FlyoutPageSample.MainPage".
1>Done building project "FlyoutPageSample.csproj" -- FAILED.
1>AppFlyout.xaml(11,18): XamlC error XFC0004: Missing default constructor for "FlyoutPageSample.MainPage".
1>Done building project "FlyoutPageSample.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I tried looking for a working example of dependency injection while using FlyOutPage and did not find any.

Is it not supported yet ? if it does , can we have a working example for it ?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.