English 中文(简体)
在MVVERLight 简易Ioc注册已经瞬时的班级
原标题:Registering an already instantiated class in MVVMLight s SimpleIoc

I m从使用静态注射器转向使用简单的Ioc。 在简易Ioc中,有“Register<TClass>”;“Func<TClass>”;“工厂”;“简易Ioc”采用“级

我对待这一点是正确的,或者国际移民学会总是需要在登记时建立这种制度吗? 我是否应当使用这种方法来登记这一类别? 您请我举例说明如何做到这一点?

This is the Silverlight code I m trying to update. EDIT: moved my approach to an answer

最佳回答

我把我的榜样从我的问题转移到回答,因为没有人在22天里回答了这个问题。 EDIT:情况较好。

   public partial class App : Application
   {               
            /// <summary>
            /// Initializes a new instance of the <see cref="App"/> class.
            /// </summary>
            public App()
            {
              this.Startup += (s, e) =>
              {
                // create and register it now
                SimpleIoc.Default.Register<IUserToken>(() => { return new UserToken(); });
                 SimpleIoc.Default.GetInstance<IUserToken>().PopulateUserTokenFromService(() =>
                {
                  // don t do anything until the user token is populated from the server
                  InitializeComponent();                 

                  this.RootVisual = new View();
                });
              }
            }
问题回答

暂无回答




相关问题
Silverlight Rich text box control

Our team decided that we need our own custom Rich text box control for Silverlight app we are developing. We looked at existing controls mentioned at A good rich text control for Silverlight but ...

Silverlight ImageBrush not rendering (with Bing Map Control)

I m trying to add an image to a Pushpin instance from the Silverlight Bing Map Control, but I can t seem to get it to render (the pushpin renders fine). This is probably a general WPF question rather ...

Silverlight OpenFileDialog DoEvents equivalent

I m processing large files after they are selected by the user. My code looks like the following: if (FileDialog.ShowDialog() == true) { // process really big file } This freezes up the UI so ...

list of controls with templates in silverlight

Does anyone know where to find a list of controls that you can set the template on in Silverlight? I ve wasted several hours now trying to create control templates only to find that the control doesn ...

Silverlight, Updating the UI during processing

I have a simple silverlight multifile upload application, and i want to provide the user with some feedback, right now its only in a test phase and i dont have the webservice. Somehow i cant get the ...

Silverlight 3 - FindName returns null

This looks a bug to me.. Using Silverlight 3 and i have a user control defined in XAML and trying to access the object during runtime returns a null. <Grid> <common:CommonGridEditPanel x:...

silverlight 3 collection binding

Someone please help me understand why this binding does not work... I have a class called SelectionManager with a property called dates which is populated by a WCF service. The property is an ...