【问题标题】:How to display GIF Image from URL in UWP using XAML?如何使用 XAML 在 UWP 中显示来自 URL 的 GIF 图像?
【发布时间】:2017-07-02 10:10:01
【问题描述】:

我想在我的应用中显示来自以下 URL 的此 GIF:

Click here

我无法通过常规流程实现这一点,它只是显示没有任何动画的图像。

【问题讨论】:

  • 显示gif可能是您的应用程序的问题,因为浏览器通常支持GIF格式
  • GIF 和动画 GIF 仅在周年更新及更高版本中受支持。

标签: c# windows xaml uwp


【解决方案1】:

我不知道什么不适合你,但我很快做了一个演示项目,GIF 显示很好。

MainPage.xaml:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Image Height="200" Width="200" Source="{x:Bind ImageSource, Mode=OneWay}"/>
</Grid>

MainPage.xaml.cs

public sealed partial class MainPage : Page
    {
        private string ImageSource { get; set; }
        public MainPage()
        {
            this.InitializeComponent();
            ImageSource = @"http://api.wunderground.com/api/9270a990901ad2ce/animatedradar/animatedsatellite/image.gif?num=5&delay=50&rad.maxlat=47.709&rad.maxlon=-69.263&rad.minlat=31.596&rad.minlon=-97.388&rad.width=640&rad.height=480&rad.rainsnow=1&rad.reproj.automerc=1&rad.num=5&sat.maxlat=47.709&sat.maxlon=-69.263&sat.minlat=31.596&sat.minlon=-97.388&sat.width=640&sat.height=480&sat.key=sat_ir4_bottom&sat.gtt=107&sat.proj=me&sat.timelabel=0&sat.num=5";
        }
    }

【讨论】:

  • 您很可能还希望将OneWay 模式添加到您的x:Bind 中。
  • OneWay 或 OneTime 无关紧要,除非您还向 ImageSouce 属性添加更改通知。
  • 谢谢!它有效另一个查询:我正在尝试使用 url BitmapImage i2 = new BitmapImage(new Uri("api.wunderground.com/api/9270a990901ad2ce/radar/…", UriKind.Absolute));我想通过修改上面的位图语法来定义和插入我的自定义 centerlat 和 centerlon,我尝试使用不起作用的 string.format 解析参数 lat 和 lon。谢谢!
猜你喜欢
  • 2016-12-12
  • 2021-06-26
  • 2020-06-25
  • 1970-01-01
  • 2017-01-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-12
相关资源
最近更新 更多