|
|
|
@ -16,7 +16,7 @@ namespace Avalonia.Controls |
|
|
|
/// <summary>
|
|
|
|
/// A control that displays a block of formatted text.
|
|
|
|
/// </summary>
|
|
|
|
public class RichTextBlock : TextBlock, IInlineHost, IAddChild<string>, IAddChild<Inline>, IAddChild<IControl> |
|
|
|
public class RichTextBlock : TextBlock, IInlineHost |
|
|
|
{ |
|
|
|
public static readonly StyledProperty<bool> IsTextSelectionEnabledProperty = |
|
|
|
AvaloniaProperty.Register<RichTextBlock, bool>(nameof(IsTextSelectionEnabled), false); |
|
|
|
@ -148,6 +148,7 @@ namespace Avalonia.Controls |
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the inlines.
|
|
|
|
/// </summary>
|
|
|
|
[Content] |
|
|
|
public InlineCollection Inlines |
|
|
|
{ |
|
|
|
get => GetValue(InlinesProperty); |
|
|
|
@ -252,35 +253,6 @@ namespace Avalonia.Controls |
|
|
|
SelectionEnd = SelectionStart; |
|
|
|
} |
|
|
|
|
|
|
|
void IAddChild<string>.AddChild(string text) |
|
|
|
{ |
|
|
|
AddText(text); |
|
|
|
} |
|
|
|
|
|
|
|
void IAddChild<Inline>.AddChild(Inline inline) |
|
|
|
{ |
|
|
|
if (!HasComplexContent && !string.IsNullOrEmpty(_text)) |
|
|
|
{ |
|
|
|
Inlines.Add(_text); |
|
|
|
|
|
|
|
_text = null; |
|
|
|
} |
|
|
|
|
|
|
|
Inlines.Add(inline); |
|
|
|
} |
|
|
|
|
|
|
|
void IAddChild<IControl>.AddChild(IControl child) |
|
|
|
{ |
|
|
|
if (!HasComplexContent && !string.IsNullOrEmpty(_text)) |
|
|
|
{ |
|
|
|
Inlines.Add(_text); |
|
|
|
|
|
|
|
_text = null; |
|
|
|
} |
|
|
|
|
|
|
|
Inlines.Add(new InlineUIContainer(child)); |
|
|
|
} |
|
|
|
|
|
|
|
protected void AddText(string? text) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(text)) |
|
|
|
|