So I always praise this declarative development that Enterprise Core Objects lends itself to. Take the ViewModels – I go on and on, post after post, rambling on how amazingly fast and robust a UI built this way can be delivered.
But what if I want something really special in my UI – something that the ViewModel engine does not support. If I have do abandon the technique then I might as well skip it in the first place some might argue. Point taken. This post is for you.
In the ViewModel – editor above I have marked a little checkbox called “Content override” with red. And I also marked how it is rendered in the preview – like a square that says “OVERRIDE”. This is one way to get “odd” things into the otherwise purely declaratively defined UI.
When a ViewModel column has the “Content Override” set, an event will fire on the ViewModelUserControl (same for Silverlight, WPF, ASP.NET and windows forms), and in this event you can pretty much do want you want with the data provided for that column.
In code it can look something like this:
Note the that Override area is implemented as a Grid in WPF and Silverlight and you can add the things you want to show up here with another user control or what have you. The result of the expression for the column will be in DataContext for that very Grid.
In my case it turned out like this:
Fast, flexible and low maintenance for standard UI – what is not to like?