C1Image コントロールで使用されるイメージソースは C1GifImage クラスです。このクラスは、メディアプレイヤーと同様のコマンドを提供します。Play、Stop、および Pause メソッドを使用して、GIF アニメーションをプログラムで制御できます。Play メソッドと Stop メソッドの使用例については、次の手順に従います。
XAML |
コードのコピー
|
---|---|
<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:c1="http://schemas.componentone.com/winfx/2006/xaml"> <Grid x:Name="LayoutRoot" Background="White"> <c1:C1Image HorizontalAlignment="Left" Margin="10,10,0,0" Name="c1Image1" VerticalAlignment="Top" /> </Grid> </UserControl> |
XAML |
コードのコピー
|
---|---|
<Grid x:Name="LayoutRoot" Background="White" Height="139" Width="384"> <c1:C1Image HorizontalAlignment="Center" Margin="10,10,0,252" Name="c1Image1" Source="Images/Butterfly.gif" Width="44" /> <CheckBox Content="再生" Height="16" HorizontalAlignment="Center" Margin="10,10,0,0" Name="checkBox1" VerticalAlignment="Bottom" /> </Grid> |
C# |
コードのコピー
|
---|---|
using C1.Silverlight.Imaging; using C1.Silverlight; |
C# |
コードのコピー
|
---|---|
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(); }; } |