Hi, as every WPF developer would agree with me that handling focus in WPF is a nightmare and every now and then you come across scenarios which makes you pull your hair I recently came across one(more) such scenario and it was a tough task to make focus work properly, I think it will be useful to blog about my experience and solutions I have implemented, so here is the first and easiest part of this series.
I hope the effect of coffee is not same on our ability to code
Recently I had a requirement where I needed to find the last parent of a particular type in VisualTree. You can easily find an implementation to find the parent but was not able to find one for finding the top most parent of a given type. So I modified the current implementation to get the last parent of a given type in the hierarchy, which was not tough at all. This method is useful when you can have multiple parents of same type in hierarchy and you need to find the top most parent of type T, e.g. having multiple nested ScrollViewer’s. I will post the exact requirement I had and how this method was used to implement that in a later post.