On Fri, 6 Aug 2021 at 15:51, Greg Keogh <gfke...@gmail.com> wrote:

> It may be perhaps because it is Friday and I've lost my mind but I can't
>> seem to sort out a seemingly simple issue. I have a blazor page with a
>> button that calls a service to do something and the service returns an
>> object. What I need is to then take this returned object and pass it to a
>> different page for viewing. How can this be done?
>>
>> In an MVC controller action I would just do: return View("new view name",
>> model)
>>
>
> I know a lot of people are using various MVVM frameworks which enforce all
> sorts of patterns, some of them outlandishly complicated just to do things
> like you describe, even in small apps that might only have a few pages. I
> personally use everything built-in and detest 3rd party dependencies unless
> they are unavoidably valuable. No one in the other camp replied yet, so
> I'll give you my heretical opinion.
>
> In WPF, UWP, Xamarin Forms and Blazor I usually have a single controller
> class instance that represents the "state" of the app, it's created very
> early and lives for the lifetime of the app. It consists only of methods
> and properties that are classically bindable. One page may load an 
> Observable<Customer>
> list and if you click one it gets set in a SelectedCust property and I
> NavigateTo("/detail"). I don't directly pass data to the detail page, it's
> been set in an app-wide binding property and it's simply available to any
> page. A Blazor app is "alive" and keeps state so you can toss the MVC
> mindset and use persistent global values.
>

Thanks Greg that is very helpful.


> Using navigation and binding frameworks (or not) is a religious argument,
> and I've had a few at various meetups over the years. I cop a lot of scorn
> for my classical approach, but I try to point out that I can take my app
> "state" controller class and wrap it in a DOS command or a Xamarin app with
> minimal effort.
>
> I haven't directly answered your question, but I hope my comments are
> useful.
>
> *Greg K*
>
-- 
Thanks
Tom

Reply via email to