0
我想在UI圖像控件中顯示gif圖像。查看圖像中的gif圖像UI控件windows phone 7
我有Image image1;
image1.source = new BitmapImage(new Uri(link,UriKind.Absolute));
但Uri中的鏈接是.gif圖像。
我讀過這個:imagetool
但是我仍然不知道如何使用庫。我確實下載了庫並添加了引用,然後從中卡住,我想在代碼中設置源代碼。 你能幫忙解釋一下嗎?
我的代碼目前是這樣的:
<UserControl.Resources>
<imagetools:ImageConverter x:Key="ImageConverter" />
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid HorizontalAlignment="Right" Width="69">
<Border BorderBrush="White" BorderThickness="3" CornerRadius="7" Background="Black">
<Image Width="69" Height="69" Name="canvasImage" Stretch="UniformToFill" HorizontalAlignment="Center" VerticalAlignment="Center" ImageFailed="canvasImage_ImageFailed" />
</Border>
<Border BorderBrush="White" BorderThickness="3" CornerRadius="7" Background="Black">
<imagetools:AnimatedImage Name="canvasGifImage" Width="69" Height="69" Stretch="UniformToFill" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
</Grid>
</Grid>
In my MainPage.xaml.cs, because I don't know whether it is an png/jpg or a gif, so I have it try to load png/jpg first, if failed then try load gif in the imagetools control name canvasGifImage:
private void DisplayImage(int index, string link)
{
try
{
control1.canvasImage.Source = new BitmapImage(new Uri(link, UriKind.Absolute));
}
catch //if fail to load image as normal, do this
{
//but I dont know how to set Source for the canvasGifImage, help me here:
control1.canvasGifImage.Source = *new BitmapImage(new Uri(link, UriKind.Absolute));*
}
}
發佈您的代碼,使得它更容易看到你在做什麼,並提供相應的解決方案。 –