-
-
Save stevenhartin/5f735e8fbbc7c72c0d3ab325059228f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Grid | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | |
<Grid.Resources> | |
<ControlTemplate x:Key="Spinning_Widget"> | |
<ControlTemplate.Triggers> | |
<EventTrigger RoutedEvent="Loaded"> | |
<BeginStoryboard> | |
<BeginStoryboard.Storyboard> | |
<Storyboard> | |
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)" RepeatBehavior="Forever"> | |
<LinearDoubleKeyFrame KeyTime="0" Value="0" /> | |
<LinearDoubleKeyFrame KeyTime="0:0:2" Value="360" /> | |
</DoubleAnimationUsingKeyFrames> | |
</Storyboard> | |
</BeginStoryboard.Storyboard> | |
</BeginStoryboard> | |
</EventTrigger> | |
</ControlTemplate.Triggers> | |
<Rectangle x:Name="Root" Fill="Red" Width="50" Height="50" RenderTransformOrigin="0.5,0.5"> | |
<Rectangle.RenderTransform> | |
<RotateTransform Angle="0" /> | |
</Rectangle.RenderTransform> | |
</Rectangle> | |
</ControlTemplate> | |
<ControlTemplate x:Key="Common_Widget"> | |
<Grid Width="100" Height="100" Background="Gray"> | |
<!-- Is there any way to make it so we render a shared single instance of Spinning_Widget here - I.e. only render 1 control and duplicate it multiple times? --> | |
<Control Template="{StaticResource Spinning_Widget}" HorizontalAlignment="Center" VerticalAlignment="Center" /> | |
</Grid> | |
</ControlTemplate> | |
</Grid.Resources> | |
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> | |
<Control Template="{StaticResource Common_Widget}"/> | |
<Control Template="{StaticResource Common_Widget}"/> | |
</StackPanel> | |
</Grid> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment