Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have lebel that rotate throw the z axis
but i want to attache that aplliction to anoter labels
for that i need to style it
but i dont know how to do it
can someone else in the world can tell me the answer?



XML
 <!--from here i want to style the code so i can reuse it agiane for other button or label-->
  <Viewport3D Grid.RowSpan="2" Grid.ColumnSpan="2" Grid.Column="1">
            <Viewport3D.Camera>
                <PerspectiveCamera Position="0, -0.1, 4"/>
            </Viewport3D.Camera>
            <Viewport2DVisual3D x:Name="v2dv3d">
                <Viewport2DVisual3D.Transform>
                    <RotateTransform3D>
                        <RotateTransform3D.Rotation>
                            <AxisAngleRotation3D Angle="0" Axis="0, 1, 0" />
                        </RotateTransform3D.Rotation>
                    </RotateTransform3D>
                </Viewport2DVisual3D.Transform>
                <Viewport2DVisual3D.Geometry>
                    <MeshGeometry3D Positions="-1,1,0 -1,-1,0 1,-1,0 1,1,0"
                    TextureCoordinates="0,0 0,1 1,1 1,0" TriangleIndices="0 1 2 0 2 3"/>
                </Viewport2DVisual3D.Geometry>

                <Viewport2DVisual3D.Material>
                    <DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True" Brush="White"/>
                </Viewport2DVisual3D.Material>
<!--here is the label rotate --> <Label Content="WpfPainter" Height="77" HorizontalAlignment="Left" Margin="54,45,0,0" Name="label1" VerticalAlignment="Top" Width="193" FontSize="26" FontFamily="Trajan Pro" Opacity="0.7" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" >

                
                <Label.Triggers>
                        <EventTrigger RoutedEvent="MouseEnter">
                            <BeginStoryboard>
                                <Storyboard RepeatBehavior="0:0:4">
                                    <Rotation3DAnimation Storyboard.TargetName="v2dv3d"
                                                    Storyboard.TargetProperty="(Viewport2DVisual3D.Transform).(RotateTransform3D.Rotation)"
                                                    Duration="0:0:2"
                                                    BeginTime="0:0:0">
                                        <Rotation3DAnimation.From>
                                            <AxisAngleRotation3D Angle="0" Axis="0, 1, 0" />
                                        </Rotation3DAnimation.From>
                                        <Rotation3DAnimation.To>
                                            <AxisAngleRotation3D Angle="90" Axis="0, 1, 0" />
                                        </Rotation3DAnimation.To>
                                    </Rotation3DAnimation>
                                    <Rotation3DAnimation Storyboard.TargetName="v2dv3d"
                                                    Storyboard.TargetProperty="(Viewport2DVisual3D.Transform).(RotateTransform3D.Rotation)"
                                                    Duration="0:0:2"
                                                    BeginTime="0:0:2">
                                        <Rotation3DAnimation.From>
                                            <AxisAngleRotation3D Angle="-90" Axis="0, 1, 0" />
                                        </Rotation3DAnimation.From>
                                        <Rotation3DAnimation.To>
                                            <AxisAngleRotation3D Angle="0" Axis="0, 1, 0" />
                                        </Rotation3DAnimation.To>
                                    </Rotation3DAnimation>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </Label.Triggers>
                </Label>
            </Viewport2DVisual3D>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <DirectionalLight Color="#FFFFFFFF" Direction="0,0,-1"/>
                </ModelVisual3D.Content>
            </ModelVisual3D>
        </Viewport3D>



<!--end of the style -->
Posted
Updated 17-Nov-13 9:51am
v5
Comments
Sergey Alexandrovich Kryukov 17-Nov-13 14:49pm    
Not quite clear what do you mean by "putting into style"...
—SA
[no name] 17-Nov-13 15:58pm    
i correct my qwetion
[no name] 17-Nov-13 15:18pm    
the label rotate in the z axis and i want to use this code for other label so i need to put that code in style so i can use it to another lable or buttom

1 solution

<window x:class="WpfApplication1.Window1" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="600" Width="600" ResizeMode="CanResizeWithGrip" Loaded="Window_Loaded">
<grid>


 
Share this answer
 
Comments
[no name] 20-Nov-13 11:49am    
you didn't answer my qwestion
wher to put the style line?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900