Comments (9)
While I think it is trivial to handle this on a view by view basis with a CallMethodAction wired up in the view, I would agree that it is a common enough requirement that it would be good to have Prism just do this for you.
The only challenge is this: Prism can't do this for you unless Prism is in the loop on View/ViewModel construction. That means we could do it for any Region containment scenario, and we could also do it for any use of the VML. But we could not do anything if a developer news up their own V/VM and marries them with View-First or ViewModel-First patterns that don't involve Prism, which is also fairly common in a lot of Prism apps today.
I like the interface approach since it is consistent with other contracts that Prism goes looking for on Views/ViewModels - like IActiveAware, INavigationAware and so on.
So my only question is - does anyone have any hesitation with us supporting this if it would only be invoked if the view were constructed by a region or uses ViewModelLocator?
from prism.
I am wondering if the use-case is large enough for an app to have this built directly into Prism region functionality. I would think that having this as a behavior would be better since it allows a view to opt into the Loaded/Unloaded events without having the logic checked every time in the region lifecycle. I don't see a lot of views in a single app needing this functionality, but rather maybe just a few. I personally have never had this need, so I am curious how common this really is.
Thoughts?
from prism.
Good point, I would say I need it less than 10% of the time, and then a quick drag and drop in Blend and declaration of the method in the ViewModel and I have it wired up with a Behavior in less than a minute, so may not be worth putting "in the box"
from prism.
In Windows 8 I used to solve this with a Behavior, but only needed it on a few screens (over a span of 2 years+).
from prism.
I haven't tried this yet, but shouldn't you be able to use the InvokeCommandAction to execute a command on the loaded and unloaded events?
from prism.
Sure, that would work too, but this is one of those places where commands feel a little heavyweight to me, since there is no explicit user interaction that triggers this and there is no enable/disable that would apply to this scenario. So I always use CallMethodAction instead for a direct method invocation on the VM.
from prism.
Good points
from prism.
So if you all agree that this is not a "common enough requirement", let's close this issue.
from prism.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
from prism.
Related Issues (20)
- [BUG] Prism.Navigation getParameters failed (empty parameters) HOT 1
- [BUG] Expected Navigation Failed. No Root Window has been created. HOT 1
- [BUG][MAUI] EventToCommandBehavior with RelativeSource binding throws InvalidOperationException HOT 4
- [BUG] Content of a ContentPage doesn't occupy full height when page is pushed to PrismNavigationPage HOT 4
- [BUG] When using iOS ModalPresentationStyles that can be automatically dismissed, navigation service gets out of sync & stops working with NavigationPage HOT 2
- [BUG] Unable to unregister the service using the Prism.Maui HOT 1
- No Root Window has been created HOT 1
- [Feature Request] Add support Keyed Service for IServiceCollection HOT 2
- Resolving with Unity works, not with DryIoc HOT 3
- [Enhancement] GetNavigationUriPath For Maui HOT 3
- [BUG] Android "hardware" back button closes the app when app contains a tabbed page with a navigation page as root page for one of the tabs HOT 1
- [BUG] Getting exception while navigating in Release mode on iOS HOT 2
- [BUG] [Android] Open app from url scheme crashes app HOT 3
- [BUG] Navigation Title view is not getting displayed on IOS HOT 2
- [BUG] Navigation Title view is not getting displayed with .net 8.0 on Andriord and IOS HOT 2
- [BUG] BindingContext cleared when performing absolute navigation HOT 2
- [Enhancement] NavigateFrom
- [Enhancement] Add ability to switch tabs and navigate
- [BUG] Android "hardware" back button closes the app when app contains a tabbed page with a navigation page as root page for one of the tabs, Take 2 HOT 1
- [BUG] Popup Dialogs are hidden/covered by calling Page when called after returning from MAUI FilePicker
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prism.