Class MarkdownLinkConverter
Converts a string containing markdown style links to a TextBlock.
Implements
Namespace: Sartorius.SAF.Presentation.Converter
Assembly: Sartorius.SAF.Presentation.dll
Syntax
public class MarkdownLinkConverter : ConverterExtensionBase, IValueConverter
Examples
The following example shows how to configure a MarkdownLinkConverter.
<saf:MarkdownLinkConverter x:Key="LinkConverter" TextBlockStyle="{markup:Style TextBlock}">
<saf:MarkdownLinkConverter.HyperlinkTemplate>
<DataTemplate DataType="{x:Type Hyperlink}">
<Hyperlink NavigateUri="{Binding NavigateUri}"
Style="{markup:Style Hyperlink}"
Command="{x:Static saf:RoutedCommands.OpenUriCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=NavigateUri, Mode=OneWay}"
TextDecorations="None">
<InlineUIContainer BaselineAlignment="Bottom">
<ContentControl Style="{markup:Icon OpenAttachment}"
Margin="5 -20 0 0">
<FrameworkElement.RenderTransform>
<TranslateTransform Y="5" />
</FrameworkElement.RenderTransform>
</ContentControl>
</InlineUIContainer>
<Span saf:SpanExtensions.Inlines="{Binding Inlines}" />
</Hyperlink>
</DataTemplate>
</saf:MarkdownLinkConverter.HyperlinkTemplate>
</saf:MarkdownLinkConverter>
The following example shows how to use a MarkdownLinkConverter.
<saf:MarkdownLinkConverter x:Key="LinkConverter" TextBlockStyle="{markup:Style TextBlock}">
<saf:MarkdownLinkConverter.HyperlinkTemplate>
<DataTemplate DataType="{x:Type Hyperlink}">
<Hyperlink NavigateUri="{Binding NavigateUri}"
Style="{markup:Style Hyperlink}"
Command="{x:Static saf:RoutedCommands.OpenUriCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=NavigateUri, Mode=OneWay}"
TextDecorations="None">
<InlineUIContainer BaselineAlignment="Bottom">
<ContentControl Style="{markup:Icon OpenAttachment}"
Margin="5 -20 0 0">
<FrameworkElement.RenderTransform>
<TranslateTransform Y="5" />
</FrameworkElement.RenderTransform>
</ContentControl>
</InlineUIContainer>
<Span saf:SpanExtensions.Inlines="{Binding Inlines}" />
</Hyperlink>
</DataTemplate>
</saf:MarkdownLinkConverter.HyperlinkTemplate>
</saf:MarkdownLinkConverter>
Properties
View SourceHyperlinkTemplate
Gets or sets the template for a hyperlink.
Declaration
public DataTemplate HyperlinkTemplate { get; set; }
Property Value
| Type | Description |
|---|---|
| DataTemplate |
TextBlockStyle
Gets or sets the style for the created TextBlock.
Declaration
public Style TextBlockStyle { get; set; }
Property Value
| Type | Description |
|---|---|
| Style |
Methods
View SourceConvert(object, Type, object, CultureInfo)
Converts a value.
Declaration
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | The value produced by the binding source. |
| Type | targetType | The type of the binding target property. |
| object | parameter | The converter parameter to use. |
| CultureInfo | culture | The culture to use in the converter. |
Returns
| Type | Description |
|---|---|
| object | A converted value. If the method returns null, the valid null value is used. |