dotnet / dotnet/maui

Make the .ctor of the NavigableElement public

Open
#10,370 9 comments 0 reactions 0 assignees View on GitHub
area-architecture platform/android platform/ios platform/windows proposal/open
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 15h
Merged PRs (30d)
290

Description

### Description

Hello,
The NavigableElement is a public class but we can't inherit it because the .ctor is internal.

![image](https://user-images.githubusercontent.com/47348109/192751591-66af9a3a-4253-4872-b3c2-ca3e1a96b690.png)

Looks like a trick to resolve `sealed` inheritance - you can do it, we not.
Meanwhile, the NavigableElement implements a major feature - implicit styles, besides the shell navigation.

My question - **Is there any reason to stop NavigableElement inheritance? Could you make the .ctor public?**

### Steps to Reproduce

So, why are we here:
- MAUI doesn't support the DefaultStyle engine like WPF. We stopped using implicit style in our components and basically remove the whole XAML from our assemblies. There are performance and usage issues that we get tired to fix.
- There are special cases when we should set up the appearance of component parts, like `DataGrid.ColumnAppearance`. The `ColumnAppearance` a not presented in the visual tree as an element. It's a "logical element" that provides a way to set the properties for drawing. In this case, we need implicit styles for our customers! It's super flexible to write XAML like:
```xaml
...


<Setter Property="Background" Value="Red"/>

```

We inherited our appearance class from `VisualElement`. It's tricky and I don't really like it:
- It's WA and is not a quality solution. A lot of `VisualElement` properties (like Width, Height ...) don't work and are unnecessary.
- We faced some issues with HotReload in this case (I go to sending a separate issue)

### Link to public reproduction project repository

https://github.com/dotnet/maui

### Version with bug

6.0 Release Candidate 2 or older

### Last version that worked well

6.0 Release Candidate 2 or older

### Affected platforms

iOS, Android, Windows

### Affected platform versions

iOS 15

### Did you find any workaround?

_No response_

### Relevant log output

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating the public NavigableElement class and reviewing how its internal constructor currently prevents inheritance. Read the issue discussion and check the existing platform behavior for iOS, Android, and Windows before deciding whether exposing the constructor is appropriate. Done means the inheritance scenario is supported without breaking existing behavior, with relevant tests or validation updated if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop, frontend, mobile
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.