As I recently announced, I’ve been working on a new mobile game for Android and iOS called Mirror Maze. I’m happy to announce that Mirror Maze is now available for download on the App Store and Google Play!

Mirror Maze is a fun and challenging new take on maze games and I’m very excited to share it with the world. Go download it for your device and give it a try today. It’s good fun for all ages. If you like it, help an indie developer out and give it a good review 🙂

I developed Mirror Maze with Xamarin and CocosSharp and have already begun writing drafts for upcoming posts to share what I learned along the way. Stay tuned for my upcoming Mobile Game Development series right here.

I’ve gone dark on this blog for quite some time now, but I’m coming back out into the light to share my latest project. I’m excited to announce a new mobile game I’ve been working on for many months. Mirror Maze!

Mirror Maze is a fun and challenging new take on maze games. With Mirror Maze, your movements are mirrored as you try to complete mazes of varying complexity and difficulty. Learn more about Mirror Maze over at the marketing page.

I’ve been a mobile developer for many years now, and games have been a fun thing to develop on my own time. But this marks the first time that I’ll have an app out on the App Store, let alone the same app deployed both on Google Play and the App Store. As of this writing, v1.0 of Mirror Maze is published out on Google Play, available for Android users to enjoy, and in private beta testing out on the App Store, available for some my friends with iPhones and iPads to play with and provide feedback. I still have some hoops to jump through before going live on the App Store, but hope to finish jumping through those hoops in the next week or two.

I developed this game using Xamarin and CocosSharp. The process was a mix of lots of fun and lots of frustration. In fact, I learned so much from developing Mirror Maze that I plan to resurrect this blog to write up a series of posts outlining all the things I wish I had known before starting an app with Xamarin and CocosSharp.

Learning to develop for Windows 8 has been an interesting challenge. I hope my presentation helped you along your journey. I have made my presentation materials available for you to check out on your own terms.

On my current project, we need to open a record for editing when the DataGridRow is double clicked. Unfortunately, the WPF DataGrid doesn’t support this functionality out of the box. There are, however, a couple ways to make this happen.

One way is to handle MouseDoubleClick event on the DataGrid. We are using Caliburn.Micro, so it is easy to get the MouseDoubleClick event to route to our view model. The view model can then assume that the selected item is to be edited. The problem with this is that double clicking anywhere on the DataGrid will trigger this event, including the scrollbars. That means that quickly scrolling down the items could trigger a double click and cause whatever item was last selected to be edited, which is unacceptable.

What we needed was to somehow handle the MouseDoubleClick event on each DataGridRow, make sure the one being double clicked on is actually selected, then call tell the view model to edit it.

I ultimately came up with two solutions. One uses a little code-behind and applies only to one case at a time. The other uses an attached DependencyProperty and is general enough to apply to all cases.

Using Code-behind

The code-behind solution may break the MVVM pattern, depending on your point of view. I feel that using code-behind makes sense in cases where you have logic that is specific to your how your view represents the UI.

First, you need to create the MouseDoubleClick event handler in the code-behind.

1

2

3

4

5

6

7

8

9

protectedvoidOnMouseDoubleClick(objectsender,EventArgs args)

{

varrow=sender asDataGridRow;

if(row!=null&amp;&amp;row.IsSelected)

{

varviewModel=(MainViewModel)DataContext;

viewModel.Edit();

}

}

Next, you need the wire up each DataGridRow to use that handler for MouseDoubleClick events. You can do that with styling.

1

2

3

4

5

6

7

8

9

10

11

&lt;DataGrid

ItemsSource=&quot;{Binding People}&quot;

SelectedItem=&quot;{Binding SelectedPerson}&quot;

IsReadOnly=&quot;True&quot;&gt;

&lt;DataGrid.ItemContainerStyle&gt;

&lt;Style TargetType=&quot;DataGridRow&quot;&gt;

&lt;EventSetter Event=&quot;MouseDoubleClick&quot;

Handler=&quot;OnMouseDoubleClick&quot;/&gt;

&lt;/Style&gt;

&lt;/DataGrid.ItemContainerStyle&gt;

&lt;/DataGrid&gt;

That’s it. This solution is pretty straight-forward. However, there are two problems with the code-behind solution.

The first problem is that this solution doesn’t scale. What I mean by that is that you have to re-implement it every time you want to use it.

The second problem is that it uses code-behind. As I said earlier, I believe the use of code-behind has its place. However, I prefer to stay away from it if I can.

Using Attached DependencyProperty

The attached DependencyProperty solution uses a helper class so that it can be reused across your application. It also assumes that your DataGrid’s DataContext is your view model. If that is not the case, you will need to modify it.

This helper class ties into the DataGrid’s LoadingRow event and uses reflection to find a specified method on the DataContext and execute it. All you have left to do is use it.

1

2

3

4

5

&lt;DataGrid

ItemsSource=&quot;{Binding People}&quot;

SelectedItem=&quot;{Binding SelectedPerson}&quot;

IsReadOnly=&quot;True&quot;

helpers:RowDoubleClickHandler.MethodName=&quot;Edit&quot;/&gt;

All you need to do is provide the name of the method on your view model to execute when the double click has occurred and the rest is taken care of.

Conclusion

While it’s unfortunate that WPF doesn’t provide this functionality right out of the box, it is not difficult to implement it yourself. Silverlight suffers from this same shortcoming. This solution won’t work as-is for Silverlight. It would need to be refactored into using Behaviors instead of an attached DependencyProperty.

If you attended my presentation, Getting Dirty with Windows Phone 7, I hope you found it useful. If you would like to play with the sample application I used in my demo, I have made it available on github: https://github.com/brentedwards/GettingDirtyWithWP7. I didn’t feel the need to post my slide deck. However, here are the valuable links I had listed:

If you attended my presentation, Getting Dirty with Android, I hope you were able to learn a thing or two. If you want to review what I covered or play with the sample application that I worked with during the demos, I have made both available.