поэтому я унаследовал разработку приложения WPF, использующего Caliburn.Micro. Мне было поручено расширить приложение и включить некоторые функции AddIn, я закодировал основную логику для функции AddIn, которая работает очень хорошо, пока я не запустил приложение, и представление оболочки не сообщает мне, что оно «Не удается найти представление для TestViewModel»WPF MVVM load View и ViewModel с внешней сборки
Вот мой метод Configure в загрузчике
protected override void Configure()
{
this._log.Debug("-->AppBootstrapper.Configure[ENTER]");
try
{
SplashScreenForm.SplashScreen.Dispatcher.BeginInvoke(
(Action)(() => SplashScreenForm.SplashScreen.Message = "Initializing Container..."));
this._container = new CompositionContainer(new AggregateCatalog(new DirectoryCatalog(".", "*")));
var batch = new CompositionBatch();
SplashScreenForm.SplashScreen.Dispatcher.BeginInvoke(
(Action)(() => SplashScreenForm.SplashScreen.Message = "Initializing Dependencies..."));
batch.AddExportedValue<IWindowManager>(new WindowManager());
batch.AddExportedValue<IEventAggregator>(new EventAggregator());
batch.AddExportedValue(this._container);
this._container.Compose(batch);
}
catch (Exception ex)
{
this._log.ErrorFormat("-->AppBootstrapper.Configure - {0}\n{1}", ex.Message, ex);
throw new Exception(ex.Message, ex);
}
this._log.Debug("-->AppBootstrapper.Configure[EXIT]");
}
Я тогда два узла, AppMain, который содержит основную логику приложения (это имеет ViewModels и вид на папки и эти все нагрузки штрафа), я также имею Узел AppAddinTest, содержащий тестовое дополнение, также содержит папку ViewModels и Views.
Мой TestViewModel код:
[Export(typeof(TestViewModel))]
public class TestViewModel : BaseViewModel, ITestViewModel
{
private readonly IEventAggregator _eventAggregator;
private readonly IWindowManager _windowManager;
[ImportingConstructor]
public TestViewModel(IEventAggregator eventAggregator, IWindowManager windowManager)
{
this._eventAggregator = eventAggregator;
this._windowManager = windowManager;
}
}
И TestView.xaml является:
<UserControl x:Class="Cleo.Windows.Ui.Views.TestView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TextBlock Text="This is a test view from a different assembly!!"></TextBlock>
</Grid>
</UserControl>
Может кто-нибудь пролить свет на то, что я сделал не так, пожалуйста, а также, почему приложение не может найти вид?