0

我在 xaml 中创建了一个动画,我希望在新窗口中播放第二部分。我当然可以在登录动画完成后打开一个新的并播放它,但我想知道我是否可以留在同一个窗口中,但使用不同的 xaml 文件。

<Window x:Class="TestWpfAnimation1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="600" Width="1000"
    WindowStartupLocation="CenterScreen">
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>
    <StackPanel Grid.Row="1"
                Grid.ColumnSpan="2"
                VerticalAlignment="Center"
                HorizontalAlignment="Center">
        <StackPanel x:Name="StackPanelName"
                    Orientation="Horizontal"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center">
            <StackPanel.RenderTransform>
                <TranslateTransform X="0" />
            </StackPanel.RenderTransform>
            <Label Content="_Name:"
                   Target="{Binding ElementName=TextBoxName}" />
            <TextBox Height="19"
                     Width="110"
                     Margin="18.55,0,0,0" />
        </StackPanel>
        <StackPanel x:Name="StackPanelPassword"
                    Orientation="Horizontal"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center">
            <StackPanel.RenderTransform>
                <TranslateTransform />
            </StackPanel.RenderTransform>
            <Label Content="_Password:" />
            <PasswordBox Height="19"
                         Width="110" />
        </StackPanel>
        <Button
            Content="Log in"
            HorizontalAlignment="Center"
            VerticalAlignment="Bottom"
            Width="60"
            IsDefault="True"
            Margin="0,13,0,0"
            Grid.Row="1"
            Grid.ColumnSpan="2">
            <Button.Triggers>
                <EventTrigger RoutedEvent="Button.Click">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
                                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0" />
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="StackPanelName"
                                                           Storyboard.TargetProperty="RenderTransform.(TranslateTransform.X)">
                                <EasingDoubleKeyFrame KeyTime="0:0:0.5"
                                                      Value="0" />
                                <EasingDoubleKeyFrame KeyTime="0:0:1.5"
                                                      Value="-381" />
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="StackPanelName"
                                                           Storyboard.TargetProperty="Opacity">
                                <EasingDoubleKeyFrame KeyTime="0:0:0.5"
                                                      Value="1" />
                                <EasingDoubleKeyFrame KeyTime="0:0:1.5"
                                                      Value="0" />
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="StackPanelPassword"
                                                           Storyboard.TargetProperty="RenderTransform.(TranslateTransform.X)">
                                <EasingDoubleKeyFrame KeyTime="0:0:0.5"
                                                      Value="0" />
                                <EasingDoubleKeyFrame KeyTime="0:0:1.5"
                                                      Value="381" />
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="StackPanelPassword"
                                                           Storyboard.TargetProperty="Opacity">
                                <EasingDoubleKeyFrame KeyTime="0:0:0.5"
                                                      Value="1" />
                                <EasingDoubleKeyFrame KeyTime="0:0:1.5"
                                                      Value="0" />
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ImageProfilePicture"
                                                           Storyboard.TargetProperty="Opacity">
                                <EasingDoubleKeyFrame KeyTime="0:0:1.5"
                                                      Value="0"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:2"
                                                      Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="StackPanelNameTitle"
                                                           Storyboard.TargetProperty="Opacity">
                                <EasingDoubleKeyFrame KeyTime="0:0:2"
                                                      Value="0" />
                                <EasingDoubleKeyFrame KeyTime="0:0:3"
                                                      Value="1" />
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Button.Triggers>
        </Button>
    </StackPanel>
    <StackPanel Orientation="Horizontal"
                HorizontalAlignment="Left"
                VerticalAlignment="Top">
        <Rectangle x:Name="ImageProfilePicture"
                   Fill="Black"
                   Height="50"
                   Width="50"
                   HorizontalAlignment="Left"
                   Margin="10,10,0,0" 
                   Opacity="0"/>
        <StackPanel x:Name="StackPanelNameTitle"
                    VerticalAlignment="Center"
                    Opacity="0">
            <TextBlock Text="First Last name"
                       Margin="8,0,0,0"
                       FontSize="13"
                       FontWeight="SemiBold"/>
            <TextBlock Text="Student"
                       HorizontalAlignment="Center"/>
        </StackPanel>
    </StackPanel>
</Grid>

4

0 回答 0