diff --git a/build/CoreLibraries.props b/build/CoreLibraries.props
index 314d38190a..9448a31d73 100644
--- a/build/CoreLibraries.props
+++ b/build/CoreLibraries.props
@@ -3,8 +3,6 @@
-
-
diff --git a/samples/BindingDemo/BindingDemo.csproj b/samples/BindingDemo/BindingDemo.csproj
index 2c6ff74e5e..bd6054327f 100644
--- a/samples/BindingDemo/BindingDemo.csproj
+++ b/samples/BindingDemo/BindingDemo.csproj
@@ -5,6 +5,7 @@
+
diff --git a/samples/ControlCatalog/ControlCatalog.csproj b/samples/ControlCatalog/ControlCatalog.csproj
index 7cbd8a3f9c..e5f07c90c3 100644
--- a/samples/ControlCatalog/ControlCatalog.csproj
+++ b/samples/ControlCatalog/ControlCatalog.csproj
@@ -25,6 +25,8 @@
+
+
diff --git a/samples/ControlCatalog/Pages/TextBoxPage.xaml b/samples/ControlCatalog/Pages/TextBoxPage.xaml
index dec5f74da8..e3d0c5e4e2 100644
--- a/samples/ControlCatalog/Pages/TextBoxPage.xaml
+++ b/samples/ControlCatalog/Pages/TextBoxPage.xaml
@@ -66,6 +66,12 @@
FontFamily="Comic Sans MS"
InputMethod.IsInputMethodEnabled="False"
Foreground="Red"/>
+
diff --git a/samples/IntegrationTestApp/IntegrationTestApp.csproj b/samples/IntegrationTestApp/IntegrationTestApp.csproj
index e8338adae6..4284399357 100644
--- a/samples/IntegrationTestApp/IntegrationTestApp.csproj
+++ b/samples/IntegrationTestApp/IntegrationTestApp.csproj
@@ -1,4 +1,4 @@
-
+
WinExe
net6.0
@@ -18,6 +18,7 @@
+
diff --git a/samples/PlatformSanityChecks/PlatformSanityChecks.csproj b/samples/PlatformSanityChecks/PlatformSanityChecks.csproj
index 9660d2a90d..4f7f06b529 100644
--- a/samples/PlatformSanityChecks/PlatformSanityChecks.csproj
+++ b/samples/PlatformSanityChecks/PlatformSanityChecks.csproj
@@ -7,6 +7,7 @@
+
diff --git a/samples/Previewer/Previewer.csproj b/samples/Previewer/Previewer.csproj
index c1d14cba26..98560e9ab0 100644
--- a/samples/Previewer/Previewer.csproj
+++ b/samples/Previewer/Previewer.csproj
@@ -9,6 +9,9 @@
+
+
+
diff --git a/samples/RenderDemo/RenderDemo.csproj b/samples/RenderDemo/RenderDemo.csproj
index 18a4ee5662..3c62af1eaf 100644
--- a/samples/RenderDemo/RenderDemo.csproj
+++ b/samples/RenderDemo/RenderDemo.csproj
@@ -12,6 +12,7 @@
+
diff --git a/samples/Sandbox/Sandbox.csproj b/samples/Sandbox/Sandbox.csproj
index f3c38cd96e..eab654acb6 100644
--- a/samples/Sandbox/Sandbox.csproj
+++ b/samples/Sandbox/Sandbox.csproj
@@ -10,6 +10,7 @@
+
diff --git a/samples/VirtualizationDemo/VirtualizationDemo.csproj b/samples/VirtualizationDemo/VirtualizationDemo.csproj
index 2c6ff74e5e..bd6054327f 100644
--- a/samples/VirtualizationDemo/VirtualizationDemo.csproj
+++ b/samples/VirtualizationDemo/VirtualizationDemo.csproj
@@ -5,6 +5,7 @@
+
diff --git a/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj b/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj
index cd9963a2e5..81b94b4d09 100644
--- a/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj
+++ b/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj
@@ -22,6 +22,7 @@
+
diff --git a/samples/interop/NativeEmbedSample/NativeEmbedSample.csproj b/samples/interop/NativeEmbedSample/NativeEmbedSample.csproj
index c25442b52c..2f3ea85e46 100644
--- a/samples/interop/NativeEmbedSample/NativeEmbedSample.csproj
+++ b/samples/interop/NativeEmbedSample/NativeEmbedSample.csproj
@@ -9,6 +9,7 @@
+
diff --git a/src/Avalonia.Controls/Presenters/TextPresenter.cs b/src/Avalonia.Controls/Presenters/TextPresenter.cs
index 07061940b5..ea9ae7bb0f 100644
--- a/src/Avalonia.Controls/Presenters/TextPresenter.cs
+++ b/src/Avalonia.Controls/Presenters/TextPresenter.cs
@@ -33,7 +33,7 @@ namespace Avalonia.Controls.Presenters
public static readonly StyledProperty CaretBrushProperty =
AvaloniaProperty.Register(nameof(CaretBrush));
-
+
public static readonly DirectProperty SelectionStartProperty =
TextBox.SelectionStartProperty.AddOwner(
o => o.SelectionStart,
@@ -43,7 +43,7 @@ namespace Avalonia.Controls.Presenters
TextBox.SelectionEndProperty.AddOwner(
o => o.SelectionEnd,
(o, v) => o.SelectionEnd = v);
-
+
///
/// Defines the property.
///
@@ -65,6 +65,12 @@ namespace Avalonia.Controls.Presenters
public static readonly StyledProperty TextWrappingProperty =
TextBlock.TextWrappingProperty.AddOwner();
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty LineHeightProperty =
+ TextBlock.LineHeightProperty.AddOwner();
+
///
/// Defines the property.
///
@@ -179,6 +185,15 @@ namespace Avalonia.Controls.Presenters
get => GetValue(TextWrappingProperty);
set => SetValue(TextWrappingProperty, value);
}
+
+ ///
+ /// Gets or sets the line height. By default, this is set to , which determines the appropriate height automatically.
+ ///
+ public double LineHeight
+ {
+ get => GetValue(LineHeightProperty);
+ set => SetValue(LineHeightProperty, value);
+ }
///
/// Gets or sets the text alignment.
@@ -253,7 +268,7 @@ namespace Avalonia.Controls.Presenters
get => GetValue(CaretBrushProperty);
set => SetValue(CaretBrushProperty, value);
}
-
+
public int SelectionStart
{
get
@@ -281,7 +296,7 @@ namespace Avalonia.Controls.Presenters
SetAndRaise(SelectionEndProperty, ref _selectionEnd, value);
}
}
-
+
protected override bool BypassFlowDirectionPolicies => true;
///
@@ -301,7 +316,7 @@ namespace Avalonia.Controls.Presenters
var textLayout = new TextLayout(text, typeface, FontSize, foreground, TextAlignment,
TextWrapping, maxWidth: maxWidth, maxHeight: maxHeight, textStyleOverrides: textStyleOverrides,
- flowDirection: FlowDirection);
+ flowDirection: FlowDirection, lineHeight: LineHeight);
return textLayout;
}
diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs
index 67c83ba13e..df9297ae40 100644
--- a/src/Avalonia.Controls/TextBox.cs
+++ b/src/Avalonia.Controls/TextBox.cs
@@ -79,8 +79,8 @@ namespace Avalonia.Controls
AvaloniaProperty.Register(nameof(MaxLength), defaultValue: 0);
public static readonly StyledProperty MaxLinesProperty =
- AvaloniaProperty.Register(nameof(MaxLines), defaultValue: 0);
-
+ AvaloniaProperty.Register(nameof(MaxLines), defaultValue: 0);
+
public static readonly DirectProperty TextProperty =
TextBlock.TextProperty.AddOwnerWithDataValidation(
o => o.Text,
@@ -105,6 +105,12 @@ namespace Avalonia.Controls
public static readonly StyledProperty TextWrappingProperty =
TextBlock.TextWrappingProperty.AddOwner();
+
+ ///
+ /// Defines see property.
+ ///
+ public static readonly StyledProperty LineHeightProperty =
+ TextBlock.LineHeightProperty.AddOwner();
public static readonly StyledProperty WatermarkProperty =
AvaloniaProperty.Register(nameof(Watermark));
@@ -358,6 +364,15 @@ namespace Avalonia.Controls
get { return GetValue(MaxLinesProperty); }
set { SetValue(MaxLinesProperty, value); }
}
+
+ ///
+ /// Gets or sets the line height.
+ ///
+ public double LineHeight
+ {
+ get { return GetValue(LineHeightProperty); }
+ set { SetValue(LineHeightProperty, value); }
+ }
[Content]
public string? Text
diff --git a/src/Avalonia.Themes.Default/Controls/TextBox.xaml b/src/Avalonia.Themes.Default/Controls/TextBox.xaml
index 6e3898a828..1885d3b65b 100644
--- a/src/Avalonia.Themes.Default/Controls/TextBox.xaml
+++ b/src/Avalonia.Themes.Default/Controls/TextBox.xaml
@@ -76,6 +76,7 @@
SelectionEnd="{TemplateBinding SelectionEnd}"
TextAlignment="{TemplateBinding TextAlignment}"
TextWrapping="{TemplateBinding TextWrapping}"
+ LineHeight="{TemplateBinding LineHeight}"
PasswordChar="{TemplateBinding PasswordChar}"
RevealPassword="{TemplateBinding RevealPassword}"
SelectionBrush="{TemplateBinding SelectionBrush}"
diff --git a/src/Avalonia.Themes.Fluent/Controls/TextBox.xaml b/src/Avalonia.Themes.Fluent/Controls/TextBox.xaml
index 095a2ef51f..40d9b11f7c 100644
--- a/src/Avalonia.Themes.Fluent/Controls/TextBox.xaml
+++ b/src/Avalonia.Themes.Fluent/Controls/TextBox.xaml
@@ -89,6 +89,7 @@
SelectionEnd="{TemplateBinding SelectionEnd}"
TextAlignment="{TemplateBinding TextAlignment}"
TextWrapping="{TemplateBinding TextWrapping}"
+ LineHeight="{TemplateBinding LineHeight}"
PasswordChar="{TemplateBinding PasswordChar}"
RevealPassword="{TemplateBinding RevealPassword}"
SelectionBrush="{TemplateBinding SelectionBrush}"