Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF PRISM 5 - View Injection

$
0
0

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


Viewing all articles
Browse latest Browse all 18858

Trending Articles



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