Looking for suggestions for implementing an attached property that depends on IMauiContext #20671
Unanswered
DanTravison
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have an attached property that calls a static platform method which uses IMauiContext to get the platform view. Since the property can be set programmatically, it's possible for it to be set before IMauiContext is available and I see this in some usage.
I've been trying to find a solution to this without making the attached property stateful, but the only approach I've found involves some convoluted logic of adding/removing PlatformChanging and PlatformChanged, notifying the platform code to add/remove its own subscriptions when the platform is changing and finally setting the property directly or deferring if the IMauiContext is not available.
I've concluded that I'm going about this in the wrong way but don't see an alternative.
Suggestions are appreciated?
Beta Was this translation helpful? Give feedback.
All reactions