Reputation: 14950
I have a custom class that extends Control
like so:
class TheCountry : Control
{
//...details
}
Then I have that element in my XAML:
<Canvas x:Name="mainCanvas" Height="768" Width="1536" AllowDrop="False">
<spots:TheCountry Country="Australia" Canvas.Left="1362" Canvas.Top="486" Template="{DynamicResource TheCountryIcon}" />
</Canvas>
And in my resources I have the template:
<UserControl.Resources>
<ControlTemplate x:Key="TheCountryIcon" TargetType="{x:Type spots:TheCountry}">
<Grid Width="35" Height="35">
<Image Source="{TemplateBinding Property=CountryImagePath}" Width="35" Height="35" AllowDrop="True"/>
</Grid>
</ControlTemplate>
</UserControl.Resources>
and I have the dependancy property called CountryImagePath
in my TheCountry
class, but when I run my app, I do not get the image showing up.
I have even put a break point on the getter in the dependancy property, and it does not get hit. How do I fix this?
Upvotes: 1
Views: 388
Reputation: 204239
Breakpoints in dependency properties don't actually work - WPF bypasses the getter and setter once the binding is established. Have a look at this post from Bea Stollnitz for some tips for debugging bindings:
What you're doing sounds reasonable. Are you certain the "CountryImagePage" is set correctly?
Upvotes: 1