how to rotate textblock dynamically in wpf using c#?
<p>I am trying like this but I am not getting the rotation. I am getting following error:</p>

<blockquote>
  <p>Unable to cast object of type 'System.Windows.Media.TransformGroup' to
  type 'System.Windows.Media.RotateTransform'.</p>
</blockquote>

<pre><code>TextBlock txt = new TextBlock();
txtb.Text="Sample";

var rotateAnimation = new DoubleAnimation(0, 270, TimeSpan.FromSeconds(5));

var rt = (RotateTransform)txt.RenderTransform;
rt.BeginAnimation(RotateTransform.AngleProperty, rotateAnimation);
</code></pre>