一种方法是这样的:如何自定义的ImageSource喂到图像中的XAML设置在XAML图像的ImageSource的
<Image Width="75" Height="75">
<Image.Source>
<BitmapImage UriSource={Binding Uri} DecodePixelWidth="75" DecodePixelHeight="75" />
<Image.Source>
</Image>
该代码包含一个很好的优化,因为一个潜在的大位图将被解码75x75像素。
我希望能够用我的自定义类来代替的BitmapImage这样的:
<Image Width="75" Height="75">
<Image.Source>
<custom:PictureBitmap Picture={Binding Picture} Width="75" Height="75" />
<Image.Source>
</Image>
我的应用程序实现了图片类,它映射到数据库表。图片类具有创建BitmapImage实例所需的一切。因此,PictureBitmap本质上是BitmapImage的适配器。
这是我如何开始:
public class PictureBitmap : BitmapSource
{
// TODO: create Picture Dependency Property
// TODO: create a BitmapImage from Picture
// TODO: implement abstract methods by delegating calls to BitmapImage
}
虽然的BitmapSource是抽象的,在API reference没有解释如何实现它。
有谁知道如何将自定义对象提供给Image.Source?
我的应用程序支持Windows Phone Mango(7.5)及更高版本。
谢谢!