BitmapImage.DecodePixelWidth属性已失效



我完全弄糊涂了。我尝试使用DecodePixelWidth属性,但出现错误:"在类型"BitmapImage"中找不到属性"DecodePixel Width"然后我试着用MSDN页面上的代码编译一个简单的程序:

<Grid x:Name="LayoutRoot">
    <Image Width="200">
        <Image.Source>
            <BitmapImage DecodePixelWidth="200"  UriSource="C:Documents and SettingsAll UsersDocumentsMy PicturesSample PicturesWater Lilies.jpg" />
        </Image.Source>
    </Image>
</Grid>

但这也不起作用。谷歌搜索什么也没给我。在C#中,我也出现了同样的错误。

更新。使用silverlight 4.0。

DecodePixelWidthDecodePixelHeight属性不适用于Silverlight,如您在MSDN Silverlight文档中BitmapImage所示。PixelWidthPixelHeight可用,但仅作为getter属性。

最新更新