WPF - using CroppedBitmap in DataTemplate
问题 The following xaml works ok inside a Window : <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> But when I use the equivalent code in a DataTemplate I get the following error in run-time: Failed object initialization (ISupportInitialize.EndInit). 'Source' property is not set. Error at object 'System