You should do this way,
((TextBlock)btnPrescan.GetTemplatedChild("tbButtonText")).Text = "Your Text"
Akash Kava
2009-04-23 09:39:23
You should do this way,
((TextBlock)btnPrescan.GetTemplatedChild("tbButtonText")).Text = "Your Text"
Bind the text to a backing property on your UserControl:
<Button x:Name="btnPrescan" Margin="8" Grid.Column="2" Click="btnPrescan_Click">
<StackPanel Orientation="Horizontal">
<Image Source="Icons\Scan_Start_Icon.png" Height="14" Width="23"/>
<!-- assumes DataContext is set appropriately -->
<TextBlock Text="{Binding ButtonText}"/>
</StackPanel>
</Button>
Then just change the backing property:
this.ButtonText = "New button text";
HTH, Kent