Home > WPF > Making a Custom Binding Extension

Making a Custom Binding Extension

Recently, I was reading an article on Josh Smith’s blog about how to set the focus from inside the View Model of a MVVM pattern using a custom MarkupExtension class.  While this article was very interesting in and of itself (and I’ll definitely be employing this approach as I continue in my own MVVM adventures), the part that really caught my interest was the link to Philipp Sumi’s blog about how to write a custom a Binding extension class.

This was especially interesting to me because a couple of weeks ago, while working on a custom WPF Theme (see a future post about that), I tried to extend the DynamicResourceExtension class and encountered the same sort of problem that Philipp Sumi encountered – that the necessary parts of DynamicResourceExtension were either sealed or internal. 

Philipp’s solution was to extend MarkupExtension rather than Binding or BindingBase, and to internally create a Binding.  I believe that this approach can be used to wrap a DynamicResource markup in the same way.  I’ll delve into this in greater detail when I blog about authoring a WPF Theme in the next few weeks.

Categories: WPF Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: