The visual tree determines the rendering order of WPF visual and drawing objects. The rendering order of traversal starts with the root visual, which is the top most element in the root visual tree. The root visual’s children are then traversed, left to right. Find the following button control rendering order in visual tree.
A WIN32 application uses immediate mode graphics system wherein the application is responsible for repainting the client area when they are resized or the object’s visual appearance is changed. WPF on the contrary uses retained mode graphics system. In this mode, drawing information of an object is persisted and serialized by the application and the rendering is done by the system.
The following example uses a DoubleAnimation to rotate the textblock. The textblock performs a full rotation over a duration of 20 seconds and then continues to repeat the rotation.
[XAML]
<TextBlockName='MyRotatingText'Margin='20'Width='640'Height='100'FontSize='48'FontWeight='Bold'Foreground='Teal'
>
This is rotating text
<TextBlock.RenderTransform><RotateTransformx:Name='MyRotateTransform'Angle='0'CenterX='230'CenterY='25'/></TextBlock.RenderTransform><!-- Animates the text block’s rotation. --><TextBlock.Triggers><EventTriggerRoutedEvent='TextBlock.Loaded'><BeginStoryboard><Storyboard><DoubleAnimationStoryboard.TargetName='MyRotateTransform'Storyboard.TargetProperty='(RotateTransform.Angle)'From='0.0'To='360'Duration='0:0:10'RepeatBehavior='Forever' /></Storyboard></BeginStoryboard></EventTrigger></TextBlock.Triggers></TextBlock>
[XAML]
<!-- Hard shadow on top of soft shadow. --><TextBlockText='Shadow Text'Foreground='CornflowerBlue'><TextBlock.BitmapEffect><BitmapEffectGroup><BitmapEffectGroup.Children><DropShadowBitmapEffectShadowDepth='5'Direction='330'Color='DarkSlateBlue'Opacity='0.75'Softness='0.50' /><DropShadowBitmapEffectShadowDepth='2'Direction='330'Color='Maroon'Opacity='0.5'Softness='0.0' /></BitmapEffectGroup.Children></BitmapEffectGroup></TextBlock.BitmapEffect></TextBlock>