码迷,mamicode.com
首页 > Windows程序 > 详细

WPF 使用EventTrigger时设置SouceName技巧

时间:2020-05-06 01:37:08      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:origin   sel   sla   toolbar   dockpanel   log   tool   https   class   

原文: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>
技术图片

 

WPF 使用EventTrigger时设置SouceName技巧

标签:origin   sel   sla   toolbar   dockpanel   log   tool   https   class   

原文地址:https://www.cnblogs.com/lonelyxmas/p/12833942.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!