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.

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 *

This site uses Akismet to reduce spam. Learn how your comment data is processed.