views:

148

answers:

1

I have a control bound to an Object and all is well but I want to turn it into a control template bound to different objects of a similar type. I would like to do this exclusively in xaml, if possible. Any good tutorials that outline the steps?

<TextBlock Text="{Binding Source={StaticResource BorderControl}, Path=ControlName}"/>

EDIT: With a little more experience, it turns out what I need is the ability to Set the Binding source based on a property of the control. i.e.

<TextBlock Text="{Binding Source={StaticResource {TemplateBinding Tag}}, Path=ControlName}"/>

The control exists within a ControlTemplate but works correctly if I bind it directly to the data -- if that makes a difference. I don't know if this is possible or if it's the correct approach. Any thoughts welcome!

EDIT:

This doesn't work either.

<TextBlock Text="{Binding Source={TemplateBinding Tag}, Path=ControlName}"/>
+1  A: 

I think you want ContentPresenter here (http://msdn.microsoft.com/en-us/library/system.windows.controls.contentpresenter.aspx) - think of it as one line of an ItemsControl, it's got a content and a reference to a template that will represent that content.

Paul Betts
Thanks Paul. I didn't form the question very well. I think the edit explains it more accurately.
Brad