Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: prism: problems with dynamically adding tabitems

$
0
0

i use the following code in a controller class to add tabitems (which will contain viewSubsystemDetailsView)dynamically in the main region in response to some event:

privat void ShowSubsystemDetails(PreCommissioning.Model.SubsystemSubsys)

{

IRegion mainRegion = regionManager.Regions[RegionName.MainRegion];

bool alreadyExists = false;

foreach (var view inmainRegion.Views)

{

if (view isSubsystemDetailsView) ;

var subsysdetailsViewModel = ((FrameworkElement)view).DataContextasSubsystemDetailsViewModel;

if(subsysdetailsViewModel.Subsystem == Subsys)

{

mainRegion.Activate(view);

alreadyExists =true;

}

}

if(!alreadyExists)

{

object existingView = mainRegion.GetView("SubsystemDetailsView");

existingView =ServiceLocator.Current.GetInstance<ISubsystemDetailsView>();

subsystemDetailsViewModel.Subsystem = Subsys;

mainRegion.Add(existingView);

mainRegion.Activate(existingView);

}

}

 

the first part of the code loops through open view so if the view already exist it activates it else control go the second part which create new view in a new tabitem.

my problem is: first part doesn't implement in the right way and tabitems are duplicated and also the tab header that read from view doen't show up.

please help me to fix these problems and if there is better approach to do the same thing (through controller) please advice.

thanks in advance

 

 

 


Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>