The Ability to Stuff UIElement(s) into a TextBlock
I don't know how useful (it qualifies as hidden though) this is ... but it sure caught me off-guard when I first ran into it:
<Grid x:Name="LayoutRoot"> <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"> <Grid> <Rectangle Fill="AliceBlue" Width="25" Height="25"/> </Grid> </TextBlock> </Grid>
You could argue the following xaml could be useful (i.e. putting a graphic at the end of some text):
<Grid> <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Hello World"> <TextBlock.Resources> <DrawingBrush x:Key="exclamationPoint" Stretch="Uniform"> <DrawingBrush.Drawing> <DrawingGroup> <DrawingGroup.Children> <GeometryDrawing Brush="#FF375CE2" Geometry="F1 M 7.968,58.164L 0,58.164L 1.914,49.921L 9.882,49.921L 7.968,58.164 Z M 21.796,0L 11.054,42.148L 4.403,42.148L 13.049,0L 21.796,0 Z "/> </DrawingGroup.Children> </DrawingGroup> </DrawingBrush.Drawing> </DrawingBrush> </TextBlock.Resources> <Grid> <Rectangle Width="100" Height="100" Fill="{StaticResource exclamationPoint}"/> </Grid> </TextBlock> </Grid>
The above xaml renders like the following:
