Pass ListView SelectedItems to ViewModel in Universal apps

One of the things that WinRT devs need to work around in Universal apps is the fact that you can't bind straight to SelectedItems of a ListView/GridView. There are a few ways to pass SelectedItems to the ViewModel and here's one that can get the job done quickly. The method I'll use in this post uses EventTriggerBehavior to invoke a command in ViewModel when a SelectionChanged event occurs. For that to work, you need to add the Behaviors SDK to both of your projects (Windows and Windows Phone) in your Universal app. Whenever you want to use the classes…

Read More

MVVM Light session at Advanced Technology Days 10

I love talking about MVVM and encourage developers working with XAML platforms to at least explore it, learn more about it, and consider using it in whatever way works best for them and their team. I also love the simplicity of MVVM Light and how it's really easy to learn it and start using it quickly. I delivered a session at Microsoft Advanced Technology Days 10 event in Zagreb, Croatia, last week, and here's my presentation. The session includes some really basic info about MVVM as a pattern. Then I moved on to MVVM Light trying to cover as much…

Read More

Focus a TextBox from ViewModel using a simple behavior

Let's assume a simple scenario - you have a Windows Phone page connected to a ViewModel (VM) with everything bound nicely. A TextBox text property is connected to a string in VM, and when you change it, you wish to put focus on the TextBox. How to accomplish this considering that all your logic is actually in the VM separated from the View? Simply, using a focus behavior. Let's start with a simple UI. We have a MainPage with a TextBox and a Button in the main Grid, and the DataContext bound to a MainViewModel object. <phone:PhoneApplicationPage x:…

Read More

MVP Reconnect - say hi on Twitter

Microsoft MCSD

profile for igrali at Stack Overflow, Q&A for professional and enthusiast programmers

Latest Posts