A Rotating Wireframe Cube--silverilght4简易魔方

<UserControl x:Class="SilverlightApplication1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400" xmlns:my="clr-namespace:Liquid;assembly=Liquid.Popup" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
    <UserControl.Resources>
        <Style TargetType="Rectangle" x:Key="rectangleStyle">
            <Setter Property="Width" Value="200" />
            <Setter Property="Height" Value="200" />
            <Setter Property="Stroke" Value="Blue" />
            <Setter Property="StrokeThickness" Value="4" />
        </Style>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid HorizontalAlignment="Center"
              VerticalAlignment="Center">
            <Rectangle Style="{StaticResource rectangleStyle}" Fill="Red" Opacity="0.5">
                <Rectangle.Projection>
                    <PlaneProjection x:Name="front"
                                     LocalOffsetZ="100"
                                     RotationX="30" />
                </Rectangle.Projection>
            </Rectangle>

            <Rectangle Style="{StaticResource rectangleStyle}" Fill="Yellow" Opacity="0.5">
                <Rectangle.Projection>
                    <PlaneProjection x:Name="top"              
                                     LocalOffsetZ="100"
                                     RotationX="-60" />
                </Rectangle.Projection>
            </Rectangle>

            <Rectangle Style="{StaticResource rectangleStyle}"  Fill="Blue" Opacity="0.5">
                <Rectangle.Projection>
                    <PlaneProjection x:Name="bottom"
                                     LocalOffsetZ="100"
                                     RotationX="120" />
                </Rectangle.Projection>
            </Rectangle>

            <Rectangle Style="{StaticResource rectangleStyle}" Fill="Green" Opacity="0.5">
                <Rectangle.Projection>
                    <PlaneProjection x:Name="back"
                                     LocalOffsetZ="-100"
                                     RotationX="30" />
                </Rectangle.Projection>
            </Rectangle>
        </Grid>
    </Grid>

    <UserControl.Triggers>
        <EventTrigger>
            <BeginStoryboard>
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetName="front"
                                     Storyboard.TargetProperty="RotationY"
                                     By="360" Duration="0:0:8"
                                     RepeatBehavior="Forever" />

                    <DoubleAnimation Storyboard.TargetName="top"
                                     Storyboard.TargetProperty="RotationY"
                                     By="360" Duration="0:0:8"
                                     RepeatBehavior="Forever" />

                    <DoubleAnimation Storyboard.TargetName="bottom"
                                     Storyboard.TargetProperty="RotationY"
                                     By="360" Duration="0:0:8"
                                     RepeatBehavior="Forever" />

                    <DoubleAnimation Storyboard.TargetName="back"
                                     Storyboard.TargetProperty="RotationY"
                                     By="360" Duration="0:0:8"
                                     RepeatBehavior="Forever" />
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </UserControl.Triggers>

</UserControl>

posted on 2010-06-01 18:22  chuncn  阅读(544)  评论(0编辑  收藏  举报

导航