IoC and development time

I have a WPF application that I am using to learn MVVM and IoC.

The problem is that the Model used by one of the views expects to pull one of its dependencies in the constructor from the IoC container.

When working on this view in the Visual Studio designer, it cannot show the design because an exception is thrown in the model.

Is there a way to get around this? Can I pull my dependencies in the wrong place in the code, or is there a way that I can go through the built dependencies, perhaps through constructor injection.

Currently the IoC container is configured in code in App.xaml.cs.

The IoC container is a native video taken from this article on MSDN - http://msdn.microsoft.com/en-us/magazine/cc337885.aspx

+2


a source to share


2 answers


I faced a similar problem lately. I worked on it with the following check:



    private void UserControl_Loaded(object sender, RoutedEventArgs e)
    {
        if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(new DependencyObject()))
            Init();
    }

      

0


a source


I found that the issue was caused by declaring the ViewModel as a datacontext view in Xaml, moving it to the view's constructor, which Xaml renders correctly in the constructor.



0


a source







All Articles