Expose FindMauiContext #7515
Unanswered
michaelstonis
asked this question in
Ideas
Replies: 1 comment
-
here's another one example https://github.com/Redth/FFImageLoading.Compat/blob/main/source/FFImageLoading.Maui/MauiExtensions.cs |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
FindMauiContext
is an extension method that is used to locate theIMauiContext
for anElement
. Internally, it is used all over the application to help in different scenarios from navigation to dependency resolution and beyond.This extension would be super helpful for 3rd party library developers to be able to leverage. For example, if I wanted to extend navigation and make my own navigation wrapper, it would provide me with a fairly easy gateway to do this. As it stands today, I need to borrow this logic into my library to do this work.
The downside that I foresee in opening this method up is that it could lead to some potential misuse. Having access to the DI container directly could result in people making bad decisions.
This could be mitigated, if the method were to have the
[EditorBrowsable(EditorBrowsableState.Never)]
attribute added, so that it would only be available for people REALLY, REALLY, REALLY looking for this kind of functionality. It would at least slow someone down looking to use it and consider the decisions that they were making.Either way, I think the benefits of having this kind of functionality outweigh any potential misuse.
Reference
maui/src/Controls/src/Core/ViewExtensions.cs
Line 202 in a35b985
Beta Was this translation helpful? Give feedback.
All reactions