|
@@ -44,8 +44,8 @@ namespace Avalonia.Controls
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Defines the <see cref="Inlines"/> property.
|
|
/// Defines the <see cref="Inlines"/> property.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- public static readonly StyledProperty<InlineCollection> InlinesProperty =
|
|
|
|
|
- AvaloniaProperty.Register<RichTextBlock, InlineCollection>(
|
|
|
|
|
|
|
+ public static readonly StyledProperty<InlineCollection?> InlinesProperty =
|
|
|
|
|
+ AvaloniaProperty.Register<RichTextBlock, InlineCollection?>(
|
|
|
nameof(Inlines));
|
|
nameof(Inlines));
|
|
|
|
|
|
|
|
public static readonly DirectProperty<TextBox, bool> CanCopyProperty =
|
|
public static readonly DirectProperty<TextBox, bool> CanCopyProperty =
|
|
@@ -138,7 +138,7 @@ namespace Avalonia.Controls
|
|
|
/// Gets or sets the inlines.
|
|
/// Gets or sets the inlines.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
[Content]
|
|
[Content]
|
|
|
- public InlineCollection Inlines
|
|
|
|
|
|
|
+ public InlineCollection? Inlines
|
|
|
{
|
|
{
|
|
|
get => GetValue(InlinesProperty);
|
|
get => GetValue(InlinesProperty);
|
|
|
set => SetValue(InlinesProperty, value);
|
|
set => SetValue(InlinesProperty, value);
|
|
@@ -159,7 +159,7 @@ namespace Avalonia.Controls
|
|
|
remove => RemoveHandler(CopyingToClipboardEvent, value);
|
|
remove => RemoveHandler(CopyingToClipboardEvent, value);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- internal bool HasComplexContent => Inlines.Count > 0;
|
|
|
|
|
|
|
+ internal bool HasComplexContent => Inlines != null && Inlines.Count > 0;
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Copies the current selection to the Clipboard.
|
|
/// Copies the current selection to the Clipboard.
|
|
@@ -260,18 +260,18 @@ namespace Avalonia.Controls
|
|
|
{
|
|
{
|
|
|
if (!string.IsNullOrEmpty(_text))
|
|
if (!string.IsNullOrEmpty(_text))
|
|
|
{
|
|
{
|
|
|
- Inlines.Add(_text);
|
|
|
|
|
|
|
+ Inlines?.Add(_text);
|
|
|
|
|
|
|
|
_text = null;
|
|
_text = null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Inlines.Add(text);
|
|
|
|
|
|
|
+ Inlines?.Add(text);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
protected override string? GetText()
|
|
protected override string? GetText()
|
|
|
{
|
|
{
|
|
|
- return _text ?? Inlines.Text;
|
|
|
|
|
|
|
+ return _text ?? Inlines?.Text;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
protected override void SetText(string? text)
|
|
protected override void SetText(string? text)
|
|
@@ -301,10 +301,10 @@ namespace Avalonia.Controls
|
|
|
|
|
|
|
|
ITextSource textSource;
|
|
ITextSource textSource;
|
|
|
|
|
|
|
|
- var inlines = Inlines;
|
|
|
|
|
-
|
|
|
|
|
if (HasComplexContent)
|
|
if (HasComplexContent)
|
|
|
{
|
|
{
|
|
|
|
|
+ var inlines = Inlines!;
|
|
|
|
|
+
|
|
|
var textRuns = new List<TextRun>();
|
|
var textRuns = new List<TextRun>();
|
|
|
|
|
|
|
|
foreach (var inline in inlines)
|
|
foreach (var inline in inlines)
|
|
@@ -537,7 +537,7 @@ namespace Avalonia.Controls
|
|
|
|
|
|
|
|
switch (change.Property.Name)
|
|
switch (change.Property.Name)
|
|
|
{
|
|
{
|
|
|
- case nameof(InlinesProperty):
|
|
|
|
|
|
|
+ case nameof(Inlines):
|
|
|
{
|
|
{
|
|
|
OnInlinesChanged(change.OldValue as InlineCollection, change.NewValue as InlineCollection);
|
|
OnInlinesChanged(change.OldValue as InlineCollection, change.NewValue as InlineCollection);
|
|
|
InvalidateTextLayout();
|
|
InvalidateTextLayout();
|
|
@@ -553,7 +553,7 @@ namespace Avalonia.Controls
|
|
|
return "";
|
|
return "";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var text = Inlines.Text ?? Text;
|
|
|
|
|
|
|
+ var text = GetText();
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(text))
|
|
if (string.IsNullOrEmpty(text))
|
|
|
{
|
|
{
|