-
Notifications
You must be signed in to change notification settings - Fork 755
BBCodeBlock
What's the deal with this BBCodeBlock? Why use BBCode? It's an outdated markup language! Isn't that what XAML is for?
Good question! There are two main reasons to introduce a text markup language next to XAML.
Try to model the following really simple rich text in XAML and compare it to the BBCode equivalent.
This is a text sample with some basic formatting.
XAML
<TextBlock>
<Run Text="This is a" />
<Run Text="text" FontWeight="Bold" />
<Run Text="sample" FontStyle="Italic" />
<Run Text="with" />
<Run Text="some basic" TextDecorations="Underline" />
<Run Text="formatting." />
</TextBlock>
BBCode
<mui:BBCodeBlock BBCode="This is a [b]text[/b] [i]sample[/i] with [u]some basic[/u] formatting." />
That is only one single line of BBCode! A single string value fully describes the rich text. This also opens up ways in MVVM to expose bindable rich text messages in a view model using string data only. You wouldn't want your ViewModel to produce XAML elements for that.
What if you want to add a hyperlink to your page that navigates to an external url? You can't simply solve this in XAML alone, you need to either implement an ICommand and assign it to your Hyperlink instance, or you need to add code in the code-behind file (assuming you are not building a XBAP app). With ILinkNavigator, link navigation becomes super easy in a BBCodeBlock. The following snippet is all that is required to show a link that opens a uri in the default browser with a BBCodeBlock.
<mui:BBCodeBlock BBCode="[url=http://www.google.com]go to google[/url]" />
There is a tutorial with detailed information on internal and external page navigation and command execution.
And don't worry about performance, BBCodeBlock is fast. The included BBCodeParser is efficient, BBCode blocks are parsed in (fractions of) milliseconds.
(c) 2013-2015 First Floor Software
Getting started
- Screenshots
- Getting started
- Getting started without templates
- Predefined page layout
- Handle navigation events
Tips and tricks
Appearance
BBCode