Category Archives: MVVM

ASP.NET Adventure. My new project using SignalR.


I’m currently working on a set of applications to handle the main tasks of my family’s restaurant. This is a snapshot of the client for the kitchen. It’s on a very early state, but you can mark product orders as “Done”. It uses Entity Framework and some concepts of Domain-Driven Design. It’s also using Windows 8.1 and Windows Phone 8 for the clients (the waiters will have another kind of client to request orders to the kitchen.

SignalR is needed to notify waiters when an order is ready (or even when a product is ready). I wanted to share the progress on this! Smile For the moment, I think Windows 8 is a bit limiting in terms of layout. WPF is far more complete. But it doesn’t feel bad at all. I think the lack of Triggers for Styles will be a big headache, but some people are working on a MVVM-friendly way to face this using Visual States.

I also feel the asynchrony will be a major let down in a later stage of the solution, but with a bit of help, it can be done. I want to start it simple!

I hope you like it. The background is a bit lame, but I like blue hues! haha Open-mouthed smile

Hey, my picture appears in each order, but a picture of each waiter will appear in a few iterations, of course Smile with tongue out


ViewModels: make them right!

It’s not so simple to just make a class implement the INotifyPropertyChanged and create some properties.

Normally you have to REPRESENT a model. But how? Replicating the properties in the model that you want? Exposing the model itself using a property?

That is a good question that every MVVM lover should have asked himself when writhing a ViewModel.

You can take a look at this article. It really hits the nail on the head.

I normally expose the model directly and make UI classes that implement INotifyPropertyChanged. But I see the property mapping far more elegant and pure MVVMish 😉

What do you prefer?

¡Menús dinámicos! Harás cacota si no sabes esto

Imagina lo siguiente: Tienes un menú que se compone mediante un binding, pero resulta que es una combinación de varias colecciones. Por ejemplo, un menú que presenta una serie de opciones fijas (o variables), y entre medias, una colección enlazada con Binding. Pues colleiga, ¡se hace así!



        <!--<MenuItem Header="Menú de coña1" />

        <MenuItem Header="Menú de coña2" />


        <CollectionContainer Collection="{Binding Source={StaticResource EditorsCollectionViewSource}}" />


        <MenuItem Header="Menú de coña3" />-->



Con la ayuda de un lobo de mar que dejó su info en Internet, ¡como los buenos samaritanos de Dios!

En referencia a este error guarrero que da si no enlazas con la CollectionViewSource:

Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=FilterOptions; DataItem=null; target element is ‘CollectionContainer’ (HashCode=23627591); target property is ‘Collection’ (type ‘IEnumerable’)

¡Buen provecho, y una patada en el pecho!

Messenger en MVVM Light? ¡Cuidado con los mensajitos!

Si una vista coge un mensaje y luego se cierra, DESREGISTRA LA VISTA! porque si no lo haces, se queda recibiendo mensajines everytime Risa y es muy muy jodido de encontrar la razón.

Aquí está lo que hay que hacer, fiery man:

public NewDocumentDialog()



           Unloaded += (sender, args) => Messenger.Default.Unregister<QDFPage>(this);


           Messenger.Default.Register<QDFPage>(this, OnMessageReceived);   



       private void OnMessageReceived(QDFPage page)



           DialogResult = true;



Y esto de más abajo es la respuesta que no me han dejado publicar en StackOverflow… que quede aquí reflejada:

Thanks, thanks a lot! I was using a widow with ShowDialog. This view has a viewmodel that communicates success using the Messenger. When opened the second time, when setting the DialogResult = true, it stated “DialogResult can be set only after Window is created and shown as dialog.”

The fact is that I the older instances of the window didn’t unregister from the Messenger! They were still receiving messages! show the attempts to set their DialogResult failed, logically.

It was hard to find, but it’s FIXED!




       <i:EventTrigger EventName="MouseEnter">

           <cmd:EventToCommand Command="{Binding TestCommand,


              CommandParameter="{Binding Text,



              MustToggleIsEnabledValue="True" />