You may need to remove the old EmployeeTextBlock and add the new one into the UI.I do a little changes for your code to see the formated TextBlock:
My Xaml code is:
<Grid Name="myGrid">
<TextBlock Name="EmployeeTextBlock" Width="200" Height="60" Background="Azure" MouseDown="EmployeeTextBlock_MouseDown" ></TextBlock>
</Grid>
The event EmployeeTextBlock_MouseDown code is:
private void EmployeeTextBlock_MouseDown(object sender, MouseButtonEventArgs e)
{
var bc = new BrushConverter();
TextBlock tb = new TextBlock();
tb.FontSize = 24;
tb.TextWrapping = TextWrapping.Wrap;
tb.Foreground = ((Brush)(bc.ConvertFrom("#FF1E59D6")));
tb.Inlines.Add("Edit employee ");
tb.Inlines.Add(new Run("data.Name") { FontWeight = FontWeights.Bold });
myGrid.Children.Remove(EmployeeTextBlock);
EmployeeTextBlock = tb;
myGrid.Children.Add(EmployeeTextBlock);
}
The result picture is like:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.