Problem when executing Caliburn micro in WPF

Nov 14, 2011 at 12:25 PM

Hello,

I've successfully created a SL application with DAF and it worked great,now I tried to do the same on WPF but I got the client stuck with no application window to show up...

  public class MyBootStrapper : FrameworkBootstrapper 
    {
        protected override void InitializeCompositionBatch(CompositionBatch batch)
        {
            base.InitializeCompositionBatch(batch);
            batch.AddExportedValue>(new EntityManagerProvider());
        }
    }

 

ViewModel

 

  [Export]
    public class MainViewModel : Screen, IDiscoverableViewModel 
    {
        private readonly MyRepository _repository;


        [ImportingConstructor]
        public MainViewModel(MyRepository repository)
        {
            _repository = repository;
        }


        protected override void OnInitialize()
        {
            base.OnInitialize();
        }
    }

Repository

 [Export]
    public class MyRepository
    {
        private readonly IEntityManagerProvider _entityManagerProvider;

        [ImportingConstructor]
        public MyRepository(IEntityManagerProvider entityManagerProvider)
        {
            _entityManagerProvider = entityManagerProvider;
        }

        private MyEntities Manager { get { return _entityManagerProvider.Manager; } }
    }

 

Any suggestion on how to spot the problem?

Thanks

Coordinator
Nov 14, 2011 at 10:07 PM

In WPF, you have to put the bootstrapper inside of a ResourceDictionary in your App.xml, otherwise it doesn't get created.

<Application x:Class="WpfHarness.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:WpfHarness">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary>
                    <local:AppBootstrapper x:Key="bootstrapper" />
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>