I am using Caliburn Micro to develop WPF application. A few of views of this application needs to be loaded in an AutoCAD environment. The AutoCAD programming environment allows developement of AutoCAD plugins (of type dll) and load them into the AutoCAD environment.
Because of AutoCAD plugin type(dll), the plugin does not have an Application Object, so the bootstrapper has to be customized for that. According to the Caliburn Micro documentation here (Scroll down to "Using Caliburn.Micro in Office and WinForms Applications") we can inherit the non-generic bootstrapper and pass "false" to the base constructor's "useApplication" parameter. So, I went ahead and created the customized bootstrapper.
The issue is that the ConfigureContainer() override never gets called and nothing gets initialized. Also, I am not sure how to load the ShellView using ViewModel first concept. Here is some code that I have come up till now.
The Bootstrapper
public class AutocadMefBootStrapper : Bootstrapper {
private CompositionContainer container;
private ElementHost host;
public AutocadMefBootStrapper(ElementHost host) : base(false) {
this.host = host;
}
protected override void Configure() { //Not getting invoked.
...
var rootViewModel = container.GetExportedValue<IShell>();
var rootView = ViewLocator.LocateForModel(rootViewModel, null, null);
host.Child = rootView;
}
}
I have a windows form which the AutoCAD loads when requested. In the Windows Form's loaded event, I create an instance cuztomized caliburn micro bootstrapper and expect the boot strapper to do all the magic and load the Shell. But the Shell does not load. I get the blank window displayed in the AutoCAD. Here is how the Windows Form is coded.
public partial class WinFormHost : Form {
private void WinFormHost_Load(object sender, EventArgs e) {
ElementHost host = new ElementHost();
host.Dock = DockStyle.Fill;
Controls.Add(host);
AutocadMefBootStrapper bootStrapper = new AutocadMefBootStrapper(host);
}
}
Here is my ShellView
<UserControl x:Class="RelayAnalysis_Autocad.Views.ShellView"
...
<Grid>
<TextBlock>Hello There</TextBlock>
</Grid>
</UserControl>
and the ShellViewModel
[Export(typeof(IShell))]
public class ShellViewModel : Conductor<object>, IShell {
protected override void OnActivate() {
base.OnActivate();
}
}
So in summary, I am trying use Caliburn Micro in an hosted environment which is not loaded using the Application object. I am unable to configure Caliburn Micro, as the ShellView never loads.