110,534
社区成员
发帖
与我相关
我的任务
分享
<UserControl x:Class="MyWard.MyUserControl.ChangeImage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<Storyboard x:Key="Storyboard1">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="myImage">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:8" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:10" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="myImage">
<EasingDoubleKeyFrame KeyTime="0" Value="280"/>
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="1.5"/>
<EasingDoubleKeyFrame KeyTime="0:0:8" Value="-1.625"/>
<EasingDoubleKeyFrame KeyTime="0:0:10" Value="-304"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="myImage">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="2.833"/>
<EasingDoubleKeyFrame KeyTime="0:0:8" Value="0.708"/>
<EasingDoubleKeyFrame KeyTime="0:0:10" Value="4"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="grid">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:8" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:10" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
<UserControl.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">在这个地方怎么去修改RoutedEvient改成自定义的呢?
<BeginStoryboard x:Name="Storyboard1_BeginStoryboard" Storyboard="{StaticResource Storyboard1}"/>
</EventTrigger>
</UserControl.Triggers>
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="133*"/>
<RowDefinition Height="17*"/>
</Grid.RowDefinitions>
<Image x:Name="myImage" Grid.RowSpan="2" Source="{Binding ImageSource,UpdateSourceTrigger=PropertyChanged}" Margin="20" RenderTransformOrigin="0.5,0.5" >
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Image.RenderTransform>
</Image>
<Grid x:Name="grid" Grid.Row="1" RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Grid.RenderTransform>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="1.5*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="1">
<TextBlock Text="{Binding GameMoney,UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Right" FontSize="25" Foreground="Orange"></TextBlock>
</Grid>
<Grid Grid.Column="2">
<Image Source="/MyWard;component/Images/money.png" VerticalAlignment="Top" HorizontalAlignment="Left"></Image>
</Grid>
<!--<TextBlock Text="游戏价格:2元/次" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>-->
</Grid>
<!--<Border x:Name="border" BorderBrush="#FF15894F" Grid.RowSpan="2" BorderThickness="5" HorizontalAlignment="Left" Height="300" Margin="0,0,-1,0" VerticalAlignment="Top" Width="301" d:IsHidden="True"/>-->
</Grid>
</UserControl>
public static readonly RoutedEvent MyroutEvent = EventManager.RegisterRoutedEvent("BeginAnimation",
RoutingStrategy.Bubble, typeof (RoutedEventHandler), typeof (ChangeImage));
public event RoutedEventHandler BeginAnimation
{
add { this.AddHandler(MyroutEvent, value); }
remove { this.RemoveHandler(MyroutEvent,value); }
}
但是在xaml中的
<EventTrigger RoutedEvent="FrameworkElement.Loaded">改成MyroutEvent时,提示无法访问或者识别MyroutEvent,还是说我改变的方式不对呢?求指点