I have a custom control and I need to use platform specific code inside it. I register platform specific implementation in IPlatformInitializer
s on each platform. And I'm able to resolve instance via IUnityContainer
. But I haven't reference to unity container inside my custom control. What is the designed approach by framework developers to resolve registered instance inside my custom control? I create my control in XAML
.
With Xamarin.Forms
's approach I'm able to do:
DependencyService.Get<ISomeManager>();
from any place of an application.
Thanks in advance.
You will need to implement a service locator pattern in order to access the container in your custom control. You can cast the Application.Current to a PrismApplication and use the Container property off of it, or expose a new static property for the container.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.