Reputation: 57
I have a templated button, of which I have several attached dependency properties all working just fine with the {TemplateBinding myExtension:Item.XXX}
.
However, when I come to try and bind to an image URL, I can't do it. If I bind the URL to a textbox in the control template, it shows, but if I use the same binding on an ImageSource, I get nothing.
<Grid.Background>
<ImageBrush>
<ImageBrush.ImageSource>
<BitmapImage UriSource="{TemplateBinding extensions:ShopButton.Asset}" />
</ImageBrush.ImageSource>
</ImageBrush>
</Grid.Background>
I've tried using brackets "(extensions:ShopButtonAsset)", I've tried using different property types string/uri.
Any ideas?
Upvotes: 2
Views: 137
Reputation: 57
<ImageBrush>
<ImageBrush.ImageSource>
<Binding Path="(extensions:ShopButton.Asset)" **RelativeSource="{RelativeSource TemplatedParent}"** />
</ImageBrush.ImageSource>
</ImageBrush>
Upvotes: 0
Reputation: 34306
Try using RelativeSource instead:
<BitmapImage UriSource="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=(extensions:ShopButton.Asset)}"/>
Upvotes: 1