WPF 加载Gif动态图片并且切圆形
效果
首先在项目的依赖项增加:
加: xmlns:gif="https://github.com/XamlAnimatedGif/XamlAnimatedGif"
<Window x:Class="xxxx.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:gif="https://github.com/XamlAnimatedGif/XamlAnimatedGif"xmlns:local="clr-namespace:WPFControlsTest"mc:Ignorable="d" Background="#2d323c" Foreground="#dddddd"Title="MainWindow" Height="300" Width="620"></Window>
<Image gif:AnimationBehavior.SourceUri="{Binding AvatarUrl}" Width="30" Height="30"Stretch="UniformToFill"><Image.Clip><EllipseGeometry RadiusX="15" RadiusY="15"Center="15 15"/></Image.Clip></Image>