My Prisam Application 'Initializing modules' successFuly module view call by view Module fill. But loding view not set detacontex view module.To add modul,I can used this code:
protected override void ConfigureModuleCatalog()
{
base.ConfigureModuleCatalog();
ModuleCatalog moduleCatalog = (ModuleCatalog)this.ModuleCatalog;
moduleCatalog.AddModule(typeof(ModuleR1Customer.ViewModule.CustomerViewModules));
moduleCatalog.AddModule(typeof(ModuleR2Order.ViewModule.OrderViewModules));
}
how to solved this problem? please Help me.
This is all what you need.
- Create a general interfaces IViewModel
IView
and and special interface to that view (ITiersView
). By implementing your special interface to your View view code behind should look like below :
public interface IViewModel
{
}
public interface IView
{
IViewModel ViewModel
{
get;
set;
}
}
public interface ITiersView : IView
{
}
//My View
public partial class Tiers : UserControl , ITiersView
{
public Tiers(ITiersViewModel tiersViewModel)
{
InitializeComponent();
ViewModel = tiersViewModel;
}
public SmartStock.Infrastructure.IViewModel ViewModel
{
get
{
return (ITiersViewModel)DataContext;
}
set
{
DataContext = value;
}
}
}
To make this loads you need to use Unity container in your modulinit class like this :
_container.RegisterType<ITiersView, Tiers>();
_container.RegisterType<ITiersViewModel, TiersViewModel>();
IRegion Content = _regionManager.Regions[RegionNames.ContentRegion];
var TiersView = _container.Resolve<ITiersView>();
RibbonRegion.Add(TiersView);