ChildWindow在Open时旋转出现

在App.xaml中:

<VisualState x:Name="Open">
  <Storyboard>
    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="ContentRoot">
      <EasingDoubleKeyFrame KeyTime="0" Value="90"/>
      <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
    </DoubleAnimationUsingKeyFrames>
  </Storyboard>
</VisualState>

其次,在<Grid x:Name="ContentRoot"...> 中加入:

<Grid.Projection>
    <PlaneProjection/>
</Grid.Projection>

 下面是两个窗口翻转出现的例子:A窗口在前为调用窗口,B窗口在后为被调用窗口。

A窗口在app.xaml中的样式:

                                <VisualStateGroup x:Name="AnimationStates">
                                    <VisualState x:Name="WindowShow">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="ContentRoot">
                                                <EasingDoubleKeyFrame KeyTime="0" Value="-90"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="-90"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="WindowHide">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="ContentRoot">
                                                <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="90"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>

B窗口在app.xaml中的样式:

                                <VisualStateGroup x:Name="WindowStates">
                                    <VisualState x:Name="Open">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="ContentRoot">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="-90"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="-90"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Closed">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="ContentRoot">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="90"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>

A窗口中某一个按钮的代码:

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            VisualStateManager.GoToState(this, "WindowHide", true);
            WinB w = new WinB();
            w.Show();
            w.Closed += new EventHandler(w_Closed);
        }

        void w_Closed(object sender, EventArgs e)
        {
            VisualStateManager.GoToState(this, "WindowShow", true);
        }

 另外,RotationY的值为:

0:向前;

180:向后;

90:向左;

-90:向右。

 

 

posted @ 2013-02-17 22:51  ajeeky  阅读(225)  评论(0编辑  收藏  举报