I use caliburn micro and MEF in wpf and I have this problem.
I create shell-view-model:
public interface IShellViewModel
{
void ShowLogOnView();
void ShowMessengerView(PokecAccount account);
}
[Export(typeof(IShellViewModel))]
public class ShellViewModel : Conductor<IScreen>, IShellViewModel
{
public ShellViewModel()
{
ShowLogOnView();
}
public void ShowLogOnView()
{
ActivateItem(IoC.Get<LogOnViewModel>());
}
public void ShowMessengerView(PokecAccount account)
{
//send to constructor of MessangerViewModel paramter typeof PokecAccount(own class)
ActivateItem(IoC.Get<MessengerViewModel>(account));
}
}
From view-model I create and show in new view-model
[Export]
public class LogOnViewModel : Screen, IDataErrorInfo, ILogOnViewModel
{
[Import]
private IShellViewModel _shellViewModel;
[Import]
private IPokecConnection _pokecConn;
private PokecAccount _account;
public void LogOn(string nick, string password)
{
_account = _pokecConn.LogOn(nick, password);
if (_account != null)
{
//create new view-model and show it, problem is send parameter to construtor of MessengerViewModel
_shellViewModel.ShowMessengerView(_account);
}
}
}
Problem is here
//send to constructor of MessangerViewModel paramter typeof PokecAccount(own class)
ActivateItem(IoC.Get<MessengerViewModel>(account));
New view-model
[Export]
public class MessengerViewModel : Screen, IMessengerViewModel
{
private PokecAccount _account;
public MessengerViewModel(PokecAccount account)
{
_account = account;
}
}
Problem is here:
//send to constructor of MessangerViewModel paramter typeof PokecAccount(own class)
ActivateItem(IoC.Get<MessengerViewModel>(account));
Parameter IoC.Get() can be only string.
How solve this?