On pondering over MVVMLight for a while, I decided to take it on for my new Windows Phone 7. It was very informative watching and reading Laurent Bugnion and Jesse Liberty's blogs and videos. The one that helped me get started was The Full Stack series from Jesse, John Galoway and John Papa. Just search for "The Full Stack" in the Channel 9 web site.
I created an data entry screen, and a Save button in the Application Bar. On I went to create a RelayCommand to execute my method for saving the data. When I went to Blend, I couldn't drag-drop EventToCommand bahavior to the Save button. You should have seen me - just scratching my hair and looking confused. No, I wouldn't want you to see that face of mine anytime :)
What did I do wrong?
Well, I figured out that I was not doing anything wrong, but I was expecting a wrong thing. The EventToCommand could be used only with a FrameworkElement type. And ApplicationBar items are not. That made sense. So what do I do? How do I achieve this without writing code behind?
Well, as Laurent says in his blog, the MVVMLight cops are not going to catch me if I use code behind when using MVVMLight. So, on I went to write the code behind to execute my RelayCommand from my code behind! The only thing is that my dreams of not writing code behind has been shattered! Just Kidding!
Time to get back to my app. See Ya!
If any one is having trouble finding out a work around, and cannot solve the issue even after reading my blog, just email me - rajeevg[dot]nair[at]gmail.com. I will be glad to help you out.
I created an data entry screen, and a Save button in the Application Bar. On I went to create a RelayCommand to execute my method for saving the data. When I went to Blend, I couldn't drag-drop EventToCommand bahavior to the Save button. You should have seen me - just scratching my hair and looking confused. No, I wouldn't want you to see that face of mine anytime :)
What did I do wrong?
Well, I figured out that I was not doing anything wrong, but I was expecting a wrong thing. The EventToCommand could be used only with a FrameworkElement type. And ApplicationBar items are not. That made sense. So what do I do? How do I achieve this without writing code behind?
Well, as Laurent says in his blog, the MVVMLight cops are not going to catch me if I use code behind when using MVVMLight. So, on I went to write the code behind to execute my RelayCommand from my code behind! The only thing is that my dreams of not writing code behind has been shattered! Just Kidding!
Time to get back to my app. See Ya!
If any one is having trouble finding out a work around, and cannot solve the issue even after reading my blog, just email me - rajeevg[dot]nair[at]gmail.com. I will be glad to help you out.
No comments:
Post a Comment