Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the "run text" tag mean in XAML?

Tags:

c#

wpf

xaml

What does the "run text" tag mean in XAML?

It kind of just appeared in the XAML apparently put there by expression blend. When I do a winmerge, I noticed it from a previous release of the code.

Old:

<TextBlock VerticalAlignment="Bottom" Height="20" >^</TextBlock> 

New:

<TextBlock VerticalAlignment="Bottom" Height="20" ><Run Text="^"/></TextBlock>  
like image 990
xarzu Avatar asked Mar 24 '15 14:03

xarzu


2 Answers

TextBlock contains an Inlines collection
TextBlock.Inlines Property
Run is a type of Inline
Run is inline-level flow content
This is an example of multiple Inlines

<TextBlock Grid.Row="3" Name="myText" TextWrapping="Wrap">
    I go
    <LineBreak/>
    <Run FontStyle="Italic" Text="home"/>
</TextBlock>
like image 182
paparazzo Avatar answered Oct 19 '22 13:10

paparazzo


A TextBlock can have more than just text as its content, it could be other controls. In your new version the content of the TextBlock is a System.Windows.Documents.Run with its Text property set to ^.

This was likely done by Expression Blend because ^ could be considered a control character in some cases. By putting the text inside a Run it removes any ambiguity that the ^ is text and not some control character. When dealing with a complex designer it is always best to remove as much ambguitity as possible so Blend likely just did it to make it easier on its own parsing engine.

like image 28
Scott Chamberlain Avatar answered Oct 19 '22 12:10

Scott Chamberlain