GithubHelp home page GithubHelp logo

Comments (9)

briannoyes avatar briannoyes commented on May 22, 2024

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.

brianlagunas avatar brianlagunas commented on May 22, 2024

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.

briannoyes avatar briannoyes commented on May 22, 2024

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.

bartlannoeye avatar bartlannoeye commented on May 22, 2024

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.

brianlagunas avatar brianlagunas commented on May 22, 2024

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.

briannoyes avatar briannoyes commented on May 22, 2024

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.

brianlagunas avatar brianlagunas commented on May 22, 2024

Good points

from prism.

Jalalx avatar Jalalx commented on May 22, 2024

So if you all agree that this is not a "common enough requirement", let's close this issue.

from prism.

lock avatar lock commented on May 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.