Image > Image for Silverlight Task-Based Help > Playing or Stopping an Animated Image |
The image source used with the C1Image control is the C1GifImage class, which provides media player-like commands. You can use the C1GifImage.Play, C1GifImage.Stop, and C1GifImage.Pause methods to control GIF animations programmatically. For an example of how to use the Play and Stop methods, follow these steps:
XAML |
Copy Code
|
---|---|
<UserControl x:Class="C1Image.MainPage" 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" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400" xmlns:c1imaging="clr-namespace:C1.Silverlight.Imaging;assembly=C1.Silverlight.Imaging"> <Grid x:Name="LayoutRoot" Background="White"> <c1imaging:C1Image HorizontalAlignment="Left" Margin="10,10,0,0" Name="c1Image1" VerticalAlignment="Top" /> </Grid> </UserControl> |
XAML |
Copy Code
|
---|---|
<Grid x:Name="LayoutRoot" Background="White" Height="139" Width="384"> <c1imaging:C1Image HorizontalAlignment="Center" Margin="10,10,0,252" Name="c1Image1" Source="Images/Butterfly.gif" Width="44" /> <CheckBox Content="Play" Height="16" HorizontalAlignment="Center" Margin="10,10,0,0" Name="checkBox1" VerticalAlignment="Bottom" /> </Grid> |
using C1.Silverlight.Imaging;
using C1.Silverlight;
C# |
Copy Code
|
---|---|
public MainPage() { InitializeComponent(); var gifImage = new C1GifImage(new Uri("/Images/Butterfly.gif", UriKind.Relative)); c1Image1.Source = gifImage; checkBox1.IsChecked = true; checkBox1.Checked += delegate { gifImage.Play(); }; checkBox1.Unchecked += delegate { gifImage.Stop(); }; } |