PrismLibrary / Prism

Prism is a framework for building loosely coupled, maintainable, and testable XAML applications in WPF, Xamarin Forms, and Uno / Win UI Applications..

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Enhancement] [Regions] Add 'AddOrReplace' to IRegionBehaviorFactory

lucacivale opened this issue · comments

Summary

We want to replace an existing behavior with our custom behavior(this is already possible for region adapters). Currently we have to register custom region adapters to exclude the unwanted behavior(s). It would be a lot easier to customize behaviors if we could replace exising ones. The (old?) docs state that this was possible with the ConfigureDefaultRegionBehaviors but I didn't find this method.

API Changes

In order to replace behaviors the IRegionBehaviorFactory should expose the new AddOrReplaceIfMissing method.

.ConfigureRegionBehaviors(behaviors =>
{
    behaviors.AddOrReplaceIfMissing<CustomBehavior>(BehaviorToReplace.BehaviorKey);
})

A default implementation should be added also to IRegionBehaviorFactory to prevent breaking changes.

Intended Use Case

We need to replace the RegionManagerRegistrationBehavior to enable multiple instances of the same region with view discovery.

@dansiegel I can create a PR for this if it's approved

I want to make sure that the API's stay in sync as much as possible between the various platforms. If you want to do a PR we would certainly welcome it... but we need to make sure that we have test coverage for this across both WPF and MAUI.

Started the implementation and saw that default interface implementation isn't supported accorss all targeted runtimes. Therefore this would be a breaking change. Can I still implement it as proposed or do we need another approach?