Hi All,
Currently I am using Prism 4.1 as my component application development platform. I am using WPFMDI(http://wpfmdi.codeplex.com/) so that i can hold each view of module as a child of MdiContainer, in order to make this, i wrote below custom region adaptor:
protected override void Adapt(IRegion region, MdiContainer regionTarget)
when a view is requested via RequestNavigate, if it's not opened yet(I check this via Uri with query parameter), the view is shown as a child of mdicontaner.
if it's opened already, I need to activate it as a child of mdicontaner.
Could anyone give me some idea which region i should use, i am currently using MdiContainer as prism container, but i don't think it's good, there should be some better solution...
Currently I am using Prism 4.1 as my component application development platform. I am using WPFMDI(http://wpfmdi.codeplex.com/) so that i can hold each view of module as a child of MdiContainer, in order to make this, i wrote below custom region adaptor:
protected override void Adapt(IRegion region, MdiContainer regionTarget)
{
region.Views.CollectionChanged += (sender, e) =>
{
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
foreach (FrameworkElement element in e.NewItems)
{
IView view = element as IView;
if (null != view)
{
BaseViewModel viewModel = view.GetViewModel();
if (null != viewModel)
{
MdiChild mdiChild = new MdiChild();
if (null != viewModel.ViewObject)
{
mdiChild.Title = viewModel.ViewObject.Title;
mdiChild.Height = viewModel.ViewObject.Height;
mdiChild.Width = viewModel.ViewObject.Width;
}
mdiChild.Content = element;
regionTarget.Children.Add(mdiChild);
IRegionManagerService regionManagerService = ServiceLocator.Current.GetInstance<IRegionManagerService>();
regionManagerService.AddView(viewModel.ViewObject);
}
}
}
break;
case NotifyCollectionChangedAction.Remove:
foreach (UIElement elementLoopVariable in e.OldItems)
{
var element = elementLoopVariable;
//if (regionTarget.Items.Contains(element))
//{
// regionTarget.Items.Remove(element);
//}
}
break;
}
};
}
However, I need to implement below features:when a view is requested via RequestNavigate, if it's not opened yet(I check this via Uri with query parameter), the view is shown as a child of mdicontaner.
if it's opened already, I need to activate it as a child of mdicontaner.
Could anyone give me some idea which region i should use, i am currently using MdiContainer as prism container, but i don't think it's good, there should be some better solution...