Element Conventions & Content controls

Sep 26, 2010 at 11:03 AM


I have noticed changed the behavior when trying to specify custom element conventions w.r.t controls that have content properties.

I am using RadTransitionControls instead of ContentControls when working with Screens & conductors etc., but I have noticed that setting up such custom conventions requires a implementation of GetBindableProperty.

This is just basically a request for your article about Screens&Conductors, that you include some comments on how that GetBindableProperty works. Some time ago it was not necessary to specify it. I blindly copy and pasted your ContentControl's convention but I'd like to know how it works.


Sep 27, 2010 at 3:43 PM

The Screens/Conductors post is going to be pretty long on its own. I'm planning a post strictly on conventions. Perhaps I should do that sooner than later? Maybe I can do that after the Screens/Conductors post. In any case GetBindableProperty is called when we are trying to determine what property to bind to on your control by convention. So, assuming we have a name match, we will look up the convention for your control type. If we don't find one, we move through the base classes until we get a match. Then we pass in the control instance and expect to get the DP back. Most controls are pretty simple in that they just statically return the same DP all the time. But ContentControl is a little different because many times you want it to function as a placeholder for an injected View/ViewModel pair. So, the GetBindablePropery implementation tries to determine if that is the case. It does this by chacking to see if you have set the ContentTemplate or ContentTemplateSelector. It also checks to see if the Content is a DependencyObject or not. If you haven't set the template/selector and the content is not another control, then we assume that you are trying to bind to a ViewModel and that you need the conventional view injected. So, in that case we return the View.Model attached property instead of ContentControl.ContentProperty. The View.Model attached property then gets bound and thus invokes all the convention logic in the framework. Does that make sense? Let me know if you have any more specific questions about this and I will be happy to answer them. I'll try to get all this in the conventions article. I know there are a lot of people that want to understand this stuff better.