zoukankan      html  css  js  c++  java
  • WPF 使用EventTrigger时设置SouceName技巧

    使用情节触发器时,如果有触发源/触发源控件时可以将情节触发器放置最顶级的面板控件的触发器中。

    通过blend这个神器真的是可以学到不少东西。

    代码:

    //情节动画放置于顶级控制面板
    <Widnow.Resources>
      <Storyboard x:Key="OnMouseLeftButtonUpForGrid">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="dockPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0.675"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="0.896"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="0.997"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="dockPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0.638"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="0.835"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="0.991"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="dockPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="111"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="35.25"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="0.75"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="dockPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="-66"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="-30"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="-1.5"/>
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
    </Window.Resources>
    <Window.Triggers>
     <EventTrigger RoutedEvent="UIElement.MouseLeftButtonUp" SourceName="grid1">
                <BeginStoryboard x:Name="OnMouseLeftButtonUpForGrid_BeginStoryboard" Storyboard="{StaticResource OnMouseLeftButtonUpForGrid}"/>
            </EventTrigger>
    </Window.Triggers>
    <DockPanel x:Name="dockPanel" RenderTransformOrigin="0.5,0.5">
                <DockPanel.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform/>
                        <SkewTransform/>
                        <RotateTransform/>
                        <TranslateTransform/>
                    </TransformGroup>
                </DockPanel.RenderTransform>
                <Grid x:Name="grid1" Height="40" DockPanel.Dock="Top" Background="Red">
                    <Button x:Name="button" HorizontalAlignment="Right" Content="ccc"/>
                </Grid>
                <Grid x:Name="grid" Height="40"    VerticalAlignment="Top" DockPanel.Dock="Top" Background="Green" RenderTransformOrigin="0.5,0.5">
                </Grid>
            </DockPanel>
  • 相关阅读:
    Linux shell 学习总结
    linux shell 比较总结
    NSURL基本操作 HA
    Mac node.js install HA
    nodejs学习资料收集 HA
    xcode技巧 HA
    google web app/enxtions 学习资料收集 HA
    Failed to upload *.app on Device 可能的解决方法 HA
    iphone开发常见问题小集2 HA
    cocos2d收集 HA
  • 原文地址:https://www.cnblogs.com/T-ARF/p/11755937.html
Copyright © 2011-2022 走看看