How to activate the control in the region.

Feb 15, 2011 at 7:26 AM

Hi

I have region called "AppRegion". The AppRegion which will have lots controls with unique name. I want to activate specific control for given key name

Below code sample which is not working for me.

IRegionManager regionManager = Container.Resolve<IRegionManager>();
MainControl1 mainControl = Container.Resolve<MainControl1>();
IRegion appRegion = regionManager.Regions["AppRegion"];
appRegion.Add(mainControl,"FDMainControl");

MainControl2 mainControl = Container.Resolve<MainContro2l>();
IRegion appRegion = regionManager.Regions["AppRegion"];
appRegion.Add(mainControl, "SMPMainControl");


UserControl requiredViewObj = regionManager.Regions["AppRegion"].GetView("SMPMainControl") as UserControl;
if (requiredViewObj != null)
{
regionManager.Regions["AppRegion"].Activate(requiredViewObj);         ////Not working         
  requiredViewObj.DataContext = Container.Resolve<SMPViewModel>("SMPViewModel");
}

 

  

 

Feb 15, 2011 at 6:25 PM

You should ask this on the Prism forum. This forum is specific to the Unity DI container, not about UI composition.