Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

[BREAKING] ViewModelLocator Autowire - Use Enum #31

Merged
merged 4 commits into from
May 20, 2022
Merged

Conversation

dansiegel
Copy link
Member

Description

Prism.Forms initially introduced the ViewModelLocator.Autowire property as an Attached property which would initialize the View with the ViewModel when the property was set to True. In later versions of Prism we opted to make this a default behavior and updated this from a bool -> bool?. This results in a number of issues as the ViewModel can be initialized too early.

The ViewModelLocatorBehavior enum simply provides options for Automatic & Disabled. By default we will Autowire any View that:

  1. Has not explicitly set the Autowire property to Disabled
  2. Has a null Binding Context or as would be the case with explicitly declared children in a TabbedPage / NavigationPage not equal to the Parent or Parent Binding Context

Other Changes

  • Changes behavior of the NavigationRegistry to throw exceptions when Multiple Registrations are found or when no registrations are found
  • Adds IsRegistered check for Prism to utilize when ensuring TabbedPage & NavigationPage are registered
  • Adds helper method for future use by a NavigationBuilder to resolve the Navigation key with ViewModel first navigation

@dansiegel dansiegel added the enhancement New feature or request label May 20, 2022
@dansiegel dansiegel merged commit 58a36e9 into master May 20, 2022
@dansiegel dansiegel deleted the vml-enum branch May 20, 2022 16:21
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make ViewModelLocator.Autowire property use an Enum Type
1 participant