|
1 | 1 | --- |
2 | | -title: 建设中 |
| 2 | +title: TransitioningContentControl 内容过渡控件 |
3 | 3 | --- |
4 | 4 |
|
5 | | -建设中 |
| 5 | +主要用于变化内容的过渡呈现效果. |
| 6 | + |
| 7 | +```cs |
| 8 | +public class TransitioningContentControl : ContentControl |
| 9 | +``` |
| 10 | + |
| 11 | +# 属性 |
| 12 | + |
| 13 | +|属性|描述|默认值|备注| |
| 14 | +|-|-|-|-| |
| 15 | +|TransitionMode|过渡模式|TransitionMode.Right2Left|| |
| 16 | +|TransitionStoryboard|过渡动画|||| |
| 17 | + |
| 18 | +# 案例 |
| 19 | + |
| 20 | +```xml |
| 21 | +<Storyboard x:Key="Custom1Transition" x:Shared="False"> |
| 22 | + <DoubleAnimation From="50" To="0" Duration="0:0:0.4" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"> |
| 23 | + <DoubleAnimation.EasingFunction> |
| 24 | + <ElasticEase Oscillations="1"/> |
| 25 | + </DoubleAnimation.EasingFunction> |
| 26 | + </DoubleAnimation> |
| 27 | +</Storyboard> |
| 28 | + |
| 29 | +<Storyboard x:Key="Custom2Transition" x:Shared="False"> |
| 30 | + <DoubleAnimation From="10" To="0" Duration="0:0:0.4" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"> |
| 31 | + <DoubleAnimation.EasingFunction> |
| 32 | + <ElasticEase Oscillations="1"/> |
| 33 | + </DoubleAnimation.EasingFunction> |
| 34 | + </DoubleAnimation> |
| 35 | +</Storyboard> |
| 36 | + |
| 37 | +<Storyboard x:Key="Custom3Transition" x:Shared="False"> |
| 38 | + <DoubleAnimation From=".8" To="1" Duration="0:0:0.4" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"> |
| 39 | + <DoubleAnimation.EasingFunction> |
| 40 | + <ElasticEase Oscillations="1"/> |
| 41 | + </DoubleAnimation.EasingFunction> |
| 42 | + </DoubleAnimation> |
| 43 | +</Storyboard> |
| 44 | +``` |
| 45 | + |
| 46 | +```xml |
| 47 | +<Grid Margin="32"> |
| 48 | + <Grid.RowDefinitions> |
| 49 | + <RowDefinition Height="Auto"/> |
| 50 | + <RowDefinition/> |
| 51 | + </Grid.RowDefinitions> |
| 52 | + <ToggleButton Margin="0,0,0,32" IsChecked="True" Name="ButtonVisibilitySwitch" Style="{StaticResource ToggleButtonSwitch}"/> |
| 53 | + <UniformGrid Visibility="{Binding IsChecked,ElementName=ButtonVisibilitySwitch,Converter={StaticResource Boolean2VisibilityConverter}}" Grid.Row="1" Rows="4" Columns="3"> |
| 54 | + <hc:TransitioningContentControl> |
| 55 | + <Label HorizontalAlignment="Stretch" Content="{x:Static hc:TransitionMode.Right2Left}" Margin="32"/> |
| 56 | + </hc:TransitioningContentControl> |
| 57 | + <hc:TransitioningContentControl TransitionMode="Left2Right"> |
| 58 | + <Label HorizontalAlignment="Stretch" Content="{x:Static hc:TransitionMode.Left2Right}" Margin="32"/> |
| 59 | + </hc:TransitioningContentControl> |
| 60 | + <hc:TransitioningContentControl TransitionMode="Bottom2Top"> |
| 61 | + <Label HorizontalAlignment="Stretch" Content="{x:Static hc:TransitionMode.Bottom2Top}" Margin="32"/> |
| 62 | + </hc:TransitioningContentControl> |
| 63 | + <hc:TransitioningContentControl TransitionMode="Top2Bottom"> |
| 64 | + <Label HorizontalAlignment="Stretch" Content="{x:Static hc:TransitionMode.Top2Bottom}" Margin="32"/> |
| 65 | + </hc:TransitioningContentControl> |
| 66 | + <hc:TransitioningContentControl TransitionMode="Right2LeftWithFade"> |
| 67 | + <Label HorizontalAlignment="Stretch" Content="{x:Static hc:TransitionMode.Right2LeftWithFade}" Margin="32"/> |
| 68 | + </hc:TransitioningContentControl> |
| 69 | + <hc:TransitioningContentControl TransitionMode="Left2RightWithFade"> |
| 70 | + <Label HorizontalAlignment="Stretch" Content="{x:Static hc:TransitionMode.Left2RightWithFade}" Margin="32"/> |
| 71 | + </hc:TransitioningContentControl> |
| 72 | + <hc:TransitioningContentControl TransitionMode="Bottom2TopWithFade"> |
| 73 | + <Label HorizontalAlignment="Stretch" Content="{x:Static hc:TransitionMode.Bottom2TopWithFade}" Margin="32"/> |
| 74 | + </hc:TransitioningContentControl> |
| 75 | + <hc:TransitioningContentControl TransitionMode="Top2BottomWithFade"> |
| 76 | + <Label HorizontalAlignment="Stretch" Content="{x:Static hc:TransitionMode.Top2BottomWithFade}" Margin="32"/> |
| 77 | + </hc:TransitioningContentControl> |
| 78 | + <hc:TransitioningContentControl TransitionMode="Right2LeftWithFade"> |
| 79 | + <Label HorizontalAlignment="Stretch" Content="{x:Static hc:TransitionMode.Right2LeftWithFade}" Margin="32"/> |
| 80 | + </hc:TransitioningContentControl> |
| 81 | + <hc:TransitioningContentControl TransitionStoryboard="{StaticResource Custom1Transition}"> |
| 82 | + <Label HorizontalAlignment="Stretch" Content="Custom1" Margin="32"/> |
| 83 | + </hc:TransitioningContentControl> |
| 84 | + <hc:TransitioningContentControl TransitionStoryboard="{StaticResource Custom2Transition}"> |
| 85 | + <Label HorizontalAlignment="Stretch" Content="Custom2" Margin="32"/> |
| 86 | + </hc:TransitioningContentControl> |
| 87 | + <hc:TransitioningContentControl TransitionStoryboard="{StaticResource Custom3Transition}"> |
| 88 | + <Label HorizontalAlignment="Stretch" Content="Custom3" Margin="32"/> |
| 89 | + </hc:TransitioningContentControl> |
| 90 | + </UniformGrid> |
| 91 | +</Grid> |
| 92 | +``` |
| 93 | + |
| 94 | + |
0 commit comments