Silverlightでカスタムコントロールを作成し、generic.xamlファイルのリソースディクショナリにテンプレートを追加しました。テンプレートに加えて、StoryBoardオブジェクトをこの辞書に配置しました
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WidgetBase="clr-namespace:WidgetBase">
<Style TargetType="WidgetBase:WidgetBase">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="WidgetBase:WidgetBase">
<Border BorderBrush="Black" BorderThickness="0" CornerRadius="10">
<StackPanel x:Name="FrameContainer">
<Border BorderBrush="Black" BorderThickness=".6" HorizontalAlignment="Right" CornerRadius="10" Padding="3" MaxWidth="70" MaxHeight="30" Margin="5">
<Border.Effect>
<DropShadowEffect Color="Gray"></DropShadowEffect>
</Border.Effect>
<StackPanel Orientation="Horizontal">
<StackPanel.Resources>
<Style TargetType="Image">
<Setter Property="Width" Value="16"></Setter>
<Setter Property="Height" Value="16"></Setter>
<Setter Property="Margin" Value="3,0,3,0"></Setter>
<Setter Property="Cursor" Value="Hand"></Setter>
</Style>
</StackPanel.Resources>
<Image x:Name="MinimizeButton" Source="../Icons/Deep_Fav.png" />
<Image x:Name="RestoreButton" Source="../Icons/Deep_Faq.png" />
<Image x:Name="CloseButton" Source="../Icons/Deep_Close.png"/>
</StackPanel>
</Border>
<Border BorderBrush="Gray" x:Name="DragBorder" BorderThickness=".8" HorizontalAlignment="Right" CornerRadius="10" Background="Black" Cursor="SizeNWSE">
<ContentPresenter Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" Margin="10"/>
</Border>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
**<Storyboard x:Key="CloseAnimation">
<DoubleAnimation Storyboard.TargetProperty="UIElement.Opacity"
Duration="00:00:02" From="1.0" To="0.0"
AutoReverse="False">
</DoubleAnimation>
</Storyboard>**
コードビハインドのリソースディクショナリのストーリーボードを使用するにはどうすればよいですか?クリックイベントをテンプレートのボタンに配線しています。
(this.GetTemplateChild("CloseButton") as Image).MouseLeftButtonDown += Close;
次に、イベントハンドラーで、ユーザーコントロールでアニメーションを再生したいと思います。
plsは誰でも助けることができますか?
ありがとう。