Dependency property setter not hitting breakpoint

In WPF you probably have worked with Dependency properties(DP), you most likley have something like this:

This looks pretty straight forward and easy, right? Now try to add some custom logic in the setter of the property and run the app. You might be surprised to see that your logic in the setter is never executed! Then you start snooping and you realize that the underlying property is infact being updated. So how is it that your setter is not called???? You put a breakpoing and the breakpoint is never hit, now you must be pretty confused.

As it turns out the property is just a wrapper for the DP and the compiler actually optimizes that away, therefore your setter logic is never hit! So, if you want to have some custom logic when the property is set you should use the PropertyChangedCallback Delegate. See below:


Update Property Without a Public Setter (read-only)


**Warning** You probably should not be changing a property if the setter is not public.

The author probably had a good reason to choose that design, so if you feel you need to update it you’re probably doing it wrong!

If you’re still convinced that you must update that pesky property you may want to take a look at the code below.

Reflection comes to the rescue! Using reflection you can still change a property value.

Generic Thread Safe Event Invoker

I am pretty sure most of us are used to writing some defensive code when raising an event over and over and over.
It usually goes something like this:

So, I got tired of writing these few lines for every single event and made a utility for it. Here it is:

To call it all you have to do is:

WebAPI GET Entity from Collection

So today I was working on my first WebAPI and I ended up in a very frustrating situation. I implemented a very basic API, it only had two methods; one to list all items of an entity and one to get a single entity by it’s id. Pretty simple and straight forward right? Nothing special, you must have read dozens of posts explaining how to do it. That’s what I thought as well. Everything was all fine and well until I tried it out.

Getting the list was easy enough, but getting the entity with id just didn’t work. For “some” reason it kept going to the default get method. So I started looking at what could be the problem, but everything seemed fine. Then I started googleing around, and came back empty handed…shit…I started thinking okay there must be something wrong with my routing, let’s just say I went pretty deep into the rabbit hole.

Eventually, I figured out the problem, and I’m not proud of it. Basically your Get method responsible for the getting  a single entity **MUST** have a parameter called id(assuming you’re using the default routing rule), not myAwesomeEntityID , not failParamId, NO it’s id! That is it!

So I guess this is one of those tipical tunnel vision problems hopefully I can save someone several hours of frustration :)


Show me the codez!

This does  work:

This does not work:


Xamarin + VS2012 + PCL + MVVM Cross v3 = Awesome!!1!one1!

UPDATE (09/2013)
FYI: For Googlers that find this after 9/2013 or so. The Xamarin versions 4.1.6 and above (currently in Alpha channel) do not need these xml files anymore. And in fact they now break some nuget packages like httpclient and threading. So delete them if you made them : )


If you ever wanted to get started on mobile development this is the time! After some thinking I decided to start working on some iOS apps. I started researching online and the first thing I found was Xamarin. This in itself was pretty good as now I can focus on the device’s API rather than learning Objective-C. If you want to learn about Xamarin you may want to visit their site for some more information.

Xamarin was great but after some searching I found the ultimate life saver, MVVM Cross. Thanks to Stuart Lodge for putting it all together!

Once you put all the pieces together you end up with a solution which will have a common core (PCL) that is used by all the device (iOS, Android, WP, Windows Store, WPF) UI libraries. And best of all everything is written in C#!

So by now I think you should be thinking: “This is awesome! I wanna write some mobile apps! Let’s do this!” Well….not so fast! Getting Xamarin set up on your PC and Mac is easy that’s not hard at all.

Now, getting MVVM Cross and PCL going in VS2012 is a different story. This is a bleeding edge project, Stuart is working very hard on it, as a result a few of the posts you will find online maybe outdated. Unfortunately I had to do a fair bit of googling to finally nail it down.  Once I got it, it is pretty simple.

Go to “C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\Profile\Profile104\SupportedFrameworks” and add the two files below:

File Name: MonoAndroid,Version=v1.6+.xml
File Content:


File Name:MonoTouch,Version=v1.0+.xml

File Content:

Create an iOS solution in VS2012

Add any other UI project you wish to support.

Grab MvvmCross in NuGet for all of these projects.

Add a new project with type Portable Class Library (PCL). This will be your core library which is shared between all UIs. You will see a number of options for supported frameworks. Select the ones you want, please note if you select WP then you should select WP 7.5 or higher.

Grab MvvmCross in NUGet for this project as well.

Add a reference to your core library in each of your UI libraries.

JavaScript: AutoScrolling Stock Ticker

I’m working on a side project which will show Bitcoin prices in real time based on data collected from the different exchanges. As part of the project I wanted to display a scrolling ticker containing each exchange’s ticker information.

After some searching online I couldn’t find anything that really fit my needs. I did find a few libraries, but I thought this could be a nice challenge plus I felt having an external library for something so small is an overkill.

As a result I came up with the following solution

A few things to mention here:

The tickerHost is positioned relative to allow for left animation and the white-space is set to nowrap so it does not wrap the text which is otherwise likely to wrap.

The mainHost hides it’s overflow as tickerHost will ideally be much longer than the mainHost.

Very simply, we move the tickerHost -200 left after which we move the first ticker to the back of the list and finally we reset the position of the tickerHost.

And there you have it! It is a pretty simple solution but I believe it should do the job. Client Not Connecting

When you are hosting a site on a non standard port (for example you are running your solution out of visual studio), you may notice that your client will not connect to the socket server! This is because as it turns out the client will use your website’s port when you are creating the connection to the server. This sounds very silly to me and quite unintuitive.

I spent a good number of hours trying to isolate my solution to find the issue. Once I realized the problem it was pretty simple to fix; all you have to do is specify the port in your connection string.


Notice that I’m not specifying the port here.


Notice the ports.


Fix(specify port):


As you can see no more errors; my socket is receiving messages from the server.GoodSocket

VS 2012 Update 2 is Out

I’m always excited when MS releases new versions of their software. On April 4 Visual Studio 2012 Update 2 was released. You can grab it from the MS Download Center ( In terms of what it brings; you can check out the official announcement page (


Personally, I’m excited about three things that this update brings:

  • Blend for VS 2012
  • XAML crash fixes
  • Improved team explorer

CallerMemberName = ViewModel Properties Easy Mode

Forget about maintaining your ViewModel’s property names in nasty strings! Yep, you heard it; c# 5 comes to the rescue. Basically you no longer have to pass in the property name when you are calling your PropertChanged event caller. All you need to do is decorate your method with [CallerMemberName] and voila it’s all taken care of!



Notice how I don’t pass in anything into  RaisePropertyChanged() when it’s being called to notify the UI.

AutoGrid – Simple Grids….Faster!

UntitledAre you tired of having to manage your Grid’s columns and rows for each element?

Don’t you just hate it when you have to remove the middle row of your Grid?

Would you like a Grid that just simply manages all your rows and columns for you?

Well, you came to the right place! This little control(it is pretty simple and could have many improvements) will manage your Grid’s content. All you have to do is define your columns, their widths and the rest is all done automatically.

I made this control after getting really tired of maintaining field name – value forms. If you’ve made one using a Grid you know very well what I mean.

Let’s get right into it.

If you just want the source code; it is available here:


As you can see the code is pretty simple, all it does really is it will create rows based on the number of children the Grid contains and the number of columns it has defined.


We define our columns and then just put our controls in the AutoGrid.



Source Code: