Use a MultiBinding with TemplateBindings Use a MultiBinding with TemplateBindings wpf wpf

Use a MultiBinding with TemplateBindings


You could use:

<Binding Path="MyListOne" RelativeSource="{RelativeSource TemplatedParent}"/>

TemplateBinding is really just a short-hand, optimized version of the above. It is very strict in where and how it can be used (directly inside template without hierarchical path et cetera).

The XAML compiler is still pretty rubbish at giving decent feedback about these kind of issues (at least in 4.0, not tested 4.5 specifically for this). I just now had this XAML:

<ControlTemplate TargetType="...">    <Path ...>        <Path.RenderTransform>            <RotateTransform Angle="{TemplateBinding Tag}"/>        </Path.RenderTransform>    </Path></ControlTemplate>

It compiled and executed fine but was not binding the value in Tag to the rotation angle. I snooped and saw that the property was bound, but zero. Intuitively (after years of dealing with this annoyance) I changed it to this:

<ControlTemplate TargetType="...">    <Path ...>        <Path.RenderTransform>            <RotateTransform Angle="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}"/>        </Path.RenderTransform>    </Path></ControlTemplate>

And it worked fine.