Silveright 4 RelativeSource Binding with FindAncestor

The bad news. The folks at Microsoft still haven’t developed the FindAncestor relative source binding into SL4. The good news, I find a guy that was resourceful enough to write his own.

Please check out this great article. The source code is at the bottom of the article. You just need to extract the classes out and put into your own project. Took me about 5 minutes.

http://blog.thekieners.com/2010/09/08/relativesource-binding-with-findancestor-mode-in-silverlight/

I am testing it out more tonight, but seems to do the trick. So much nicer to now have my item template be able to reach the parent context.

Oh, and he even made the greatest simple addition. It has the built in feature to auto search for the nearest DIFFERENT datacontext. How great is that? Makes the xaml def even easier to write.

Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *