- Xamarin Blueprints
- Michael Williams
- 91字
- 2021-07-08 11:48:25
IoC with Windows Phone
Implementing IoC with Windows Phone is very much the same as iOS and Android. We simply add the same function, InitIoC
, at our application's starting point; in this case, it is the MainPage
constructor of the Windows Phone project (try not to get the two confused), and we call it right before the LoadApplication
function:
public MainPage() { InitializeComponent(); InitIoC(); NavigationCacheMode = NavigationCacheMode.Required; LoadApplication(new SpeechTalk.App()); } private void InitIoC() { IoC.CreateContainer(); IoC.RegisterModule(new WinPhoneModule ()); IoC.RegisterModule(new PCLModule ()); IoC.StartContainer(); }
Simple! Now we can run the Windows application.