WPF application, using Prism.
I am using a multi phase module initialiser and in the initialisation of the module I would like the module to self inspect the views and register any regions defined within.
I am using something similar to the code below to self inspect view model classes and register other things, but I have no idea how to reflect into a view.
protected void SelfInspectRegions()
{
var assm = Assembly.GetAssembly(this.GetType()).GetTypes();
foreach (var type in assm)
{
if(type.IsSubclassOf(typeof(UserControl)))
{
var a = type;
}
}
}
An example of a Tab based region (defined on a View/UserControl) I would like to self register is below;
<controls:ChTabControlModelAware x:Name="OrderProcessingDocumentDetailRegion"
cal:RegionManager.RegionManager="{Binding RegionManager, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type shells:FormShell}}}"
cal:RegionManager.RegionName="Order Processing:DocumentDetailRegion"
cal:RegionManager.RegionContext="{Binding DataContext, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="1" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<bindings:EventToCommandBehavior.EventBindings>
<bindings:EventBinding Command="{Binding SelectedDetailTabChangedCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=controls:TabControl}, Path= SelectedItem.DataContext.HeaderInfo}"
EventName="SelectionChanged" RaiseOnHandledEvents="True"
PassEventArgsToCommand="True" />
</bindings:EventToCommandBehavior.EventBindings>
</controls:ChTabControlModelAware>
Principally I would like to extract the RegionName defined in the line;
cal:RegionManager.RegionName="Order Processing:DocumentDetailRegion"
I am not sure how to do this and any help would be gratefully received
Many Thanks
Lance
Update 17/10/2018 : What I am trying to achieve.
I am writing a WPF application framework with about 30 modules (and expanding) that all subscribe to and inject services.
All my regions are declared in the view, and there's loads and loads of them. Due to developing requirements in my framework it is now necessary for modules to pre-register their regions in the module initialisation phase. One of the reasons is that some services target particular regions and have operational settings that are unique each of the individual hosts. Currently the host modules are responsible for the settings, which means a lot of cutting and pasting between modules and projects if a change is made to the service's operational settings. By the hosts pre-registering, in module initialisation the service module knows which modules use its services and can inject a settings class into the host modules settings viewModel for user interaction. The changes to operational settings only have to be modified in the service module and not in all the various host modules that use it.
I was looking for an easy way to scrape the names out of the numerous module assemblies without having to explicitly declare them or adorn the view model with a declarative attribute.