Try our conversational search powered by Generative AI!

ViewModel with Block without a Controller


I am trying to create some consistency to my blocks (i.e. title, padding, background-color) so I created a layout for a block. I followed the IPageViewModel and created a IBlockViewModel and that is the model of my layout class. T has properties about the block title, background-color, etc.. I followed the same procedures as how the pages are done from the Alloy Sample. 

That works great when I have a block that has a controller,  but for simple blocks that just display a few properties I don't have a controller (for performance reasons). The problem is that the model that is getting passed to those views is Castle.Proxies.[MyBlock].  I need it to be IBlockViewModel. Is there anyway I can adjust the model that is getting passed in without creating a Controller for all my blocks?

Is there an alternative to what I am trying to do?  Please any suggestions would be greatly appreciated.


Oct 04, 2017 18:58

why not just implement interface for all blocks that share common properties and then cast it to that interface inside view? why you need block view model? and btw, page view model is evil either ;)

Oct 05, 2017 13:43

The interface will probably work for me. I will have to adjust some of my ViewModels to implement that interface and expose some of those properties.  Thanks for the suggestion. Why do you see PageViewModel is evil?

Oct 05, 2017 18:32

Oct 06, 2017 7:28
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.