使用CroppedBitmap下面的XAML内Window
工程确定:WPF中的DataTemplate
<Border Width="45" Height="55" CornerRadius="10" >
<Border.Background>
<ImageBrush>
<ImageBrush.ImageSource>
<CroppedBitmap Source="profile.jpg" SourceRect="0 0 45 55"/>
</ImageBrush.ImageSource>
</ImageBrush>
</Border.Background>
</Border>
但是,当我使用等效代码在DataTemplate
我得到了运行时出现以下错误:
对象初始化失败 (ISupportInitialize.EndInit)。 '来源' 属性未设置。对象上的错误 'System.Windows.Media.Imaging.CroppedBitmap' 在标记文件中。
内部异常: { “ '源' 属性未设置。”}
唯一的区别是,我有CroppedBitmap
的源属性数据绑定:
<CroppedBitmap Source="{Binding Photo}" SourceRect="0 0 45 55"/>
是什么赋予了?
UPDATE:根据一个old post by Bea Stollnitz这是CroppedBitmap
的源属性的限制,因为它实现ISupportInitialize
。 (这些信息在页面下方 - 在“11:29”上搜索,你会看到)。
这是.Net 3.5 SP1的问题吗?
我知道这是一个很老的话题,但我遇到同样的问题。我需要做什么转换器? Thx任何帮助! – PitAttack76 2013-07-25 07:30:38