并行故事板

时间:2015-02-12 17:08:27

标签: .net wpf storyboard

我尝试开始一个故事板,我希望它能并行修改两个属性。

我的代码:

<Window x:Class="WpfWindowEffects.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Name="MyMainWindow" Height="0" Width="0" WindowStyle="ToolWindow">
<Window.Triggers>
    <EventTrigger RoutedEvent="Window.Loaded">
        <BeginStoryboard>
            <Storyboard>
                <DoubleAnimation AutoReverse="True" RepeatBehavior="Forever" Storyboard.TargetName="MyMainWindow" Storyboard.TargetProperty="Width" Duration="0:0:1" To="600" />
                <DoubleAnimation AutoReverse="True" RepeatBehavior="Forever" Storyboard.TargetName="MyMainWindow" Storyboard.TargetProperty="Height" To="600" Duration="0:0:1" />
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
</Window.Triggers>
<Grid>

</Grid>

但它不能并行工作...... 我想打开一个大小为0,0的窗口并将其调整为600x600。你知道另一种实现方法吗?

更新

我实现了它并且它有效。我不知道是否有更好的方法来实现这一目标。

<Window x:Class="WpfWindowEffects.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Name="MyMainWindow" WindowStyle="None" SizeToContent="WidthAndHeight" AllowsTransparency="True" Background="Transparent">
<DockPanel Height="10" Width="10" Name="MyGrid" HorizontalAlignment="Left" VerticalAlignment="Top" Background="CornflowerBlue">
    <DockPanel.Triggers>
        <EventTrigger RoutedEvent="Window.Loaded">
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetName="MyGrid" Storyboard.TargetProperty="Width" Duration="0:0:5" To="600" />
                    <DoubleAnimation Storyboard.TargetName="MyGrid" Storyboard.TargetProperty="Height" To="600" Duration="0:0:5" />
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </DockPanel.Triggers>
    <TextBlock Name="notificationTitle" Padding="5" FontSize="14" Foreground="White">
        Call Manager - Incoming Call
    </TextBlock>

    <Path Name="closeButton"  Grid.Column="1" Margin="5,10,10,0" Fill="White" Data="F1 M 2.28484e-007,1.33331L 1.33333,0L 4.00001,2.66669L 6.66667,6.10352e-005L 8,1.33331L 5.33334,4L 8,6.66669L 6.66667,8L 4,5.33331L 1.33333,8L 1.086e-007,6.66669L 2.66667,4L 2.28484e-007,1.33331 Z " />
</DockPanel>

0 个答案:

没有答案