title: Rotating Gradient gets out of canvas in WPF
body: <p>I wanna make a counting down timer with a slowly rotating gradient background in WPF but i'm all new to WPF.
  Problem is the whole border rotates and it gets out of canvas.</p>
  
  <p>Here is my code:</p>
  
  <p><strong>XML:</strong></p>
  
  <pre><code>    &lt;Grid&gt;
          &lt;Border Margin="-483,-164,-690,-147" RenderTransformOrigin="0.5,0.5" &gt;
              &lt;Border.Background&gt;
                  &lt;LinearGradientBrush EndPoint="1.504,1.5" StartPoint="1.504,0.03" &gt;
                      &lt;GradientStop Color="#fc00ff" Offset="-0.05" /&gt;
                      &lt;GradientStop Color="#00dbde" Offset="0.7"/&gt;
  
                      &lt;LinearGradientBrush.Transform&gt;
                          &lt;RotateTransform CenterX="200" CenterY="200" Angle="0" /&gt;
  
                      &lt;/LinearGradientBrush.Transform&gt;
  
                  &lt;/LinearGradientBrush&gt;
  
              &lt;/Border.Background&gt;
              &lt;Border.RenderTransform&gt;
                  &lt;RotateTransform x:Name="AnimatedRotateTransform" Angle="0" /&gt;
              &lt;/Border.RenderTransform&gt;
              &lt;Border.Triggers&gt;
                  &lt;EventTrigger RoutedEvent="MouseDown"&gt;
                      &lt;BeginStoryboard&gt;
                          &lt;Storyboard&gt;
                              &lt;DoubleAnimation Storyboard.TargetName="AnimatedRotateTransform" 
                                                   Storyboard.TargetProperty="Angle" 
                                                   By="10"        
                                                   To="360" 
                                                   Duration="0:2:0" 
                                                   FillBehavior="Stop" /&gt;
  
                          &lt;/Storyboard&gt;
                      &lt;/BeginStoryboard&gt;
                  &lt;/EventTrigger&gt;
              &lt;/Border.Triggers&gt;
          &lt;/Border&gt;
          &lt;TextBlock Name="tbTime" Text="00:30:00" Margin="104,112,108,119" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Exo" FontSize="66.667" Foreground="White" UseLayoutRounding="False" &gt;
              &lt;TextBlock.Effect&gt;
                  &lt;DropShadowEffect RenderingBias="Quality" BlurRadius="20" Direction="319" Opacity="0.2" ShadowDepth="0"/&gt;
              &lt;/TextBlock.Effect&gt;
          &lt;/TextBlock&gt;
          &lt;Image x:Name="image" HorizontalAlignment="Left" Height="100" Margin="192,210,0,0" VerticalAlignment="Top" Width="100"&gt;
              &lt;Image.Effect&gt;
                  &lt;BlurEffect RenderingBias="Quality" Radius="25"/&gt;
              &lt;/Image.Effect&gt;
          &lt;/Image&gt;
  
      &lt;/Grid&gt;
  </code></pre>
  
  <p><strong>C# Code Behind:</strong></p>
  
  <pre><code>public partial class MainWindow : Window
  {
      DispatcherTimer _timer;
      TimeSpan _time;
  
      public MainWindow()
      {
          InitializeComponent();
  
          _time = TimeSpan.FromSeconds(1800);
  
          _timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
          {
              tbTime.Text = _time.ToString("c");
              if (_time == TimeSpan.Zero) _timer.Stop();
              _time = _time.Add(TimeSpan.FromSeconds(-1));
  
          }, Application.Current.Dispatcher);
  
          _timer.Start();
  
      }
  </code></pre>