我有一个扩展Control
的自定义类,如下所示:
class TheCountry : Control
{
//...details
}
然后我在我的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>
在我的资源中,我有模板:
<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>
我的CountryImagePath
课程中有一个名为TheCountry
的依赖属性,但是当我运行我的应用程序时,我没有显示该图像。
我甚至在依赖属性中的getter上设置了一个断点,并且它没有被击中。我该如何解决这个问题?
答案 0 :(得分:1)
依赖项属性中的断点实际上不起作用 - 一旦建立绑定,WPF就会绕过getter和setter。看看Bea Stollnitz的这篇文章,了解调试绑定的一些技巧:
你做的事听起来很合理。您确定“CountryImagePage”设置正确吗?