I want to inject a view dynamically into ContentRegion using View Injection. Prior to this code base below there is another view
TaskDefaultView which is present. I want to replace this view with TaskOperationTypeView
TaskOpeationTypeView=> is a .xaml user Control
ContentRegion => is the region to inject the TaskOpeationTypeView
_regionManager.RegisterViewWithRegion("ContentRegion", () =>
ServiceLocator.Current.GetInstance<TaskOpeationTypeView>());
var region = _regionManager.Regions["ContentRegion"];
//region.Add(tempView);
var currentView = region.GetView("TaskOpeationTypeView");
current view is always null though in debug mode I see both views present.
if (currentView != null) region.Activate(currentView);
//Shell.xaml
<StackPanel Grid.Row="0" Background="BurlyWood" HorizontalAlignment="Left" Width="1900" Grid.ColumnSpan="2"><ContentControl x:Name="NorthRegion"
prism:RegionManager.RegionName="NorthRegion"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch" />
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="0" Background="NavajoWhite" HorizontalAlignment="Left" Width="200" >
<ContentControl x:Name="WestRegion"
prism:RegionManager.RegionName="WestRegion"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch" />
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" Background="OldLace" HorizontalAlignment="Right" Width="1500" >
<ContentControl x:Name="ContentRegion"
prism:RegionManager.RegionName="ContentRegion"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch" />
RAJ - DeepMinds