RichText Class
namespace NoesisApp
Adds a Text attached property for TextBlock which formats BBCode into Inlines.
Default supported BBCode tags, with their Inline output:
- b: Bold
- i: Italic
- u: Underline
- size: Span with FontSize set to the parameter value
- font: Span with FontFamily set to the parameter value
- color: Span with Foreground set to the parameter value
- style: Span with the Style property set to the resource key provided by the parameter value
- img: Image contained in an InlineUIContainer
- bind: Run containing a Binding with the Path property set to the tag contents. This tag has an optional "format" parameter which can be used to modify the StringFormat property of the Binding.
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">
<TextBlock noesis:RichText.Text="Plain. [b]Bold, [i]bold italic, [/i]
[size=60]Size 60 text.[/size] [img height=80]disk.png[/img]" />
</Grid>
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">
<Grid.Resources>
<Style x:Key="Header1" TargetType="{x:Type Span}">
<Setter Property="FontSize" Value="30"/>
<Setter Property="Foreground" Value="Green"/>
</Style>
</Grid.Resources>
<TextBlock noesis:RichText.Text="[style='Header1']Styled text.[/style]" />
</Grid>
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions"
xmlns:local="clr-namespace:MyGame">
<Grid.DataContext>
<local:MyViewModel CurrentHealth="66.75" MaxHealth="100" />
</Grid.DataContext>
<TextBlock noesis:RichText.Text="Health is [bind format='{0:0}']CurrentHealth[/bind] out of
[bind format='{0:0}']MaxHealth[/bind]" />
</Grid>
Properties
RichText has no properties
Methods
RichText has no methods