Reputation: 15
I want to create a region inside the DataTemplate. My requirement is, after Injecting views in TabControl, lets says Tab A, Tab B, Tab C. After that I want to create a region inside a Tab A, so that I can injecting the views inside Tab A. Means in button click, I can inject a view inside the StackPanel region. Please help me out.
<ContentControl >
<ContentControl.ContentTemplate>
<DataTemplate>
<StackPanel prism:RegionManager.RegionName="ChildRegion" prism:RegionManager.RegionManager="{Binding Value, Source={StaticResource ObservableRegionManager}}">
<TextBlock Grid.Row="0" Text="View A" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="48"></TextBlock>
<Button Grid.Row="1" Command="{Binding RelativeSource= {RelativeSource FindAncestor, AncestorType={x:Type ContentControl}},
Path=DataContext.NavigateCommand}" CommandParameter="ViewB">Navigate ViewB in Scoped Region</Button>
</StackPanel>
</DataTemplate>
</ContentControl.ContentTemplate>
</ContentControl>
I applied the below suggestion still not getting any success.
Throwing error views not registered.
Upvotes: 0
Views: 264
Reputation:
As you have discovered, using Regions inside of DataTemplates is not supported in Prism. Since you are using a custom solution to achieve this, it will be difficult to help, especially since you have not posted any of the code. Due to the nature of extending Prism, even if you did post some code it would most likely not help anyone diagnose your issue.
My suggestion is to not use DataTemplate that contain regions. I wouldn't use DataTemplate to represent entire views anyways, with or without regions.
I suggest you watch this course:
https://app.pluralsight.com/library/courses/prism-mastering-tabcontrol/table-of-contents
This should help.
Upvotes: 0