一種方法是這樣的:如何自定義的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)及更高版本。
謝謝!