I have the following control template;
<ControlTemplate x:Key="NationalTweetLabel" TargetType="{x:Type Label}">
<Grid Width="447" Height="129" RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform AngleX="0" AngleY="0"/>
<RotateTransform Angle="0"/>
<TranslateTransform X="0" Y="0"/>
</TransformGroup>
</Grid.RenderTransform>
<Border Margin="0,0,0,31" VerticalAlignment="Stretch" Width="447" Height="97" Opacity="1" Background="#FF00FF18">
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Width="448" Height="72.5" Text="{Binding Message}" TextWrapping="Wrap"/>
</Border>
<TextBlock Name="Tweet" HorizontalAlignment="Right" Margin="0,0,45,8" VerticalAlignment="Bottom" Text="{Binding User}" TextWrapping="Wrap" d:LayoutOverrides="Height" RenderTransformOrigin="6.98,1.161"/>
<Image HorizontalAlignment="Right" Margin="0,0,-9.5,-6" VerticalAlignment="Bottom" Width="51" Height="44" d:LayoutOverrides="Height" Source="bluebird.png"/>
<Image Margin="0,0,0,31.5" Source="Images\top-message-layer.png"/>
</Grid>
</ControlTemplate>
The text property of the textblock "Tweet" is set to a binding source, which I want to be a string called User. I create a label in code and apply the template to it;
TextBlock textBlock = new TextBlock();
textBlock.Template =(ControlTemplate)FindResource("NationalTweetLabel");
I don't know how to set the source of the binding for the Tweet textblock. I found code to get the element of the control template using textBlock.Template.FindName, but I don't know what to do with it after. Any help will be appreciated. Let me know if I haven't explained clearly enough.