TabbedPage: Add Content page with Constructor Dependencies
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 290
Description
### Description
The Tabbed Page seems to not support dependency injection
### Steps to Reproduce
Create a Tabbed page like
If the Page requires a Dependency like this
public partial class AddressSelectionPage : ContentPage {
public AddressSelectionPage(ViewModelAddress viewModelAddress) {
InitializeComponent();
}
}
and all the parts are added to the DI framework:
builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
builder.Services.AddTransient();
I get a Build-Error:
- Missing Default Constructor for AddressSelectionPage
-

### Version with bug
6.0 (current)
### Last version that worked well
Unknown/Other
### Affected platforms
Windows, I was *not* able test on other platforms
### Affected platform versions
any
### Did you find any workaround?
_No response_
### Relevant log output
_No response_
Contributor guide
Research direction
Start by reproducing the XAML TabbedPage containing AddressSelectionPage and the constructor that requires ViewModelAddress, with the shown services registered in DI. Trace the build-time page creation and verify that a TabbedPage can contain pages with constructor dependencies without requiring a default constructor; done means the sample builds successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100