diff --git a/api/Avalonia.nupkg.xml b/api/Avalonia.nupkg.xml
index af46d2fb2e..98a74e5485 100644
--- a/api/Avalonia.nupkg.xml
+++ b/api/Avalonia.nupkg.xml
@@ -1,4 +1,4 @@
-
+
@@ -49,6 +49,18 @@
baseline/Avalonia/lib/net10.0/Avalonia.Base.dll
current/Avalonia/lib/net10.0/Avalonia.Base.dll
+
+ CP0002
+ F:Avalonia.Controls.TextBlock.LetterSpacingProperty
+ baseline/Avalonia/lib/net10.0/Avalonia.Controls.dll
+ current/Avalonia/lib/net10.0/Avalonia.Controls.dll
+
+
+ CP0002
+ F:Avalonia.Controls.TextBox.LetterSpacingProperty
+ baseline/Avalonia/lib/net10.0/Avalonia.Controls.dll
+ current/Avalonia/lib/net10.0/Avalonia.Controls.dll
+
CP0002
F:Avalonia.Media.Fonts.FontCollectionBase._glyphTypefaceCache
@@ -103,6 +115,18 @@
baseline/Avalonia/lib/net8.0/Avalonia.Base.dll
current/Avalonia/lib/net8.0/Avalonia.Base.dll
+
+ CP0002
+ F:Avalonia.Controls.TextBlock.LetterSpacingProperty
+ baseline/Avalonia/lib/net8.0/Avalonia.Controls.dll
+ current/Avalonia/lib/net8.0/Avalonia.Controls.dll
+
+
+ CP0002
+ F:Avalonia.Controls.TextBox.LetterSpacingProperty
+ baseline/Avalonia/lib/net8.0/Avalonia.Controls.dll
+ current/Avalonia/lib/net8.0/Avalonia.Controls.dll
+
CP0002
M:Avalonia.Dialogs.Internal.ManagedFileChooserFilterViewModel.#ctor(Avalonia.Platform.Storage.FilePickerFileType)
@@ -445,4 +469,4 @@
baseline/Avalonia/lib/netstandard2.0/Avalonia.Base.dll
current/Avalonia/lib/netstandard2.0/Avalonia.Base.dll
-
+
\ No newline at end of file
diff --git a/samples/ControlCatalog/Pages/ButtonsPage.xaml b/samples/ControlCatalog/Pages/ButtonsPage.xaml
index 62fe5c7d7f..f13581aa18 100644
--- a/samples/ControlCatalog/Pages/ButtonsPage.xaml
+++ b/samples/ControlCatalog/Pages/ButtonsPage.xaml
@@ -91,6 +91,8 @@
+
+
Disabled
+
+
diff --git a/src/Avalonia.Controls/Documents/TextElement.cs b/src/Avalonia.Controls/Documents/TextElement.cs
index 1d02161689..cac8d6f97f 100644
--- a/src/Avalonia.Controls/Documents/TextElement.cs
+++ b/src/Avalonia.Controls/Documents/TextElement.cs
@@ -76,6 +76,21 @@ namespace Avalonia.Controls.Documents
Brushes.Black,
inherits: true);
+ ///
+ /// Defines the property.
+ ///
+ ///
+ /// This is an inherited attached property that defines letter spacing for text.
+ /// Letter spacing is specified in pixels. Default value is 0 (normal spacing).
+ /// Positive values increase spacing between characters.
+ /// Negative values decrease spacing between characters.
+ ///
+ public static readonly AttachedProperty LetterSpacingProperty =
+ AvaloniaProperty.RegisterAttached(
+ name: nameof(LetterSpacing),
+ defaultValue: 0.0,
+ inherits: true);
+
private IInlineHost? _inlineHost;
///
@@ -149,6 +164,15 @@ namespace Avalonia.Controls.Documents
get => GetValue(ForegroundProperty);
set => SetValue(ForegroundProperty, value);
}
+
+ ///
+ /// Gets or sets the letter spacing.
+ ///
+ public double LetterSpacing
+ {
+ get => GetValue(LetterSpacingProperty);
+ set => SetValue(LetterSpacingProperty, value);
+ }
///
/// Gets the value of the attached on a control.
@@ -190,6 +214,26 @@ namespace Avalonia.Controls.Documents
control.SetValue(FontFeaturesProperty, value);
}
+ ///
+ /// Gets the value of the attached on a control.
+ ///
+ /// The control.
+ /// The letter spacing applied to the control.
+ public static double GetLetterSpacing(Control control)
+ {
+ return control.GetValue(LetterSpacingProperty);
+ }
+
+ ///
+ /// Sets the value of the attached on a control.
+ ///
+ /// The control.
+ /// The letter spacing to apply.
+ public static void SetLetterSpacing(Control control, double value)
+ {
+ control.SetValue(LetterSpacingProperty, value);
+ }
+
///
/// Gets the value of the attached on a control.
///
diff --git a/src/Avalonia.Controls/Presenters/ContentPresenter.cs b/src/Avalonia.Controls/Presenters/ContentPresenter.cs
index 3279315f9e..a5079f8344 100644
--- a/src/Avalonia.Controls/Presenters/ContentPresenter.cs
+++ b/src/Avalonia.Controls/Presenters/ContentPresenter.cs
@@ -118,6 +118,12 @@ namespace Avalonia.Controls.Presenters
public static readonly StyledProperty LineHeightProperty =
TextBlock.LineHeightProperty.AddOwner();
+ ///
+ /// Defines the property
+ ///
+ public static readonly StyledProperty LetterSpacingProperty =
+ TextElement.LetterSpacingProperty.AddOwner();
+
///
/// Defines the property
///
@@ -327,6 +333,15 @@ namespace Avalonia.Controls.Presenters
set => SetValue(LineHeightProperty, value);
}
+ ///
+ /// Gets or sets the letter spacing
+ ///
+ public double LetterSpacing
+ {
+ get => GetValue(LetterSpacingProperty);
+ set => SetValue(LetterSpacingProperty, value);
+ }
+
///
/// Gets or sets the max lines
///
diff --git a/src/Avalonia.Controls/Presenters/TextPresenter.cs b/src/Avalonia.Controls/Presenters/TextPresenter.cs
index edbcd467aa..7078650da4 100644
--- a/src/Avalonia.Controls/Presenters/TextPresenter.cs
+++ b/src/Avalonia.Controls/Presenters/TextPresenter.cs
@@ -87,7 +87,7 @@ namespace Avalonia.Controls.Presenters
/// Defines the property.
///
public static readonly StyledProperty LetterSpacingProperty =
- TextBlock.LetterSpacingProperty.AddOwner();
+ TextElement.LetterSpacingProperty.AddOwner();
///
/// Defines the property.
diff --git a/src/Avalonia.Controls/Primitives/TemplatedControl.cs b/src/Avalonia.Controls/Primitives/TemplatedControl.cs
index bd4d08ecc2..7444e187be 100644
--- a/src/Avalonia.Controls/Primitives/TemplatedControl.cs
+++ b/src/Avalonia.Controls/Primitives/TemplatedControl.cs
@@ -88,6 +88,12 @@ namespace Avalonia.Controls.Primitives
public static readonly StyledProperty ForegroundProperty =
TextElement.ForegroundProperty.AddOwner();
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty LetterSpacingProperty =
+ TextElement.LetterSpacingProperty.AddOwner();
+
///
/// Defines the property.
///
@@ -242,6 +248,15 @@ namespace Avalonia.Controls.Primitives
set => SetValue(ForegroundProperty, value);
}
+ ///
+ /// Gets or sets the letter spacing for the control's text content.
+ ///
+ public double LetterSpacing
+ {
+ get => GetValue(LetterSpacingProperty);
+ set => SetValue(LetterSpacingProperty, value);
+ }
+
///
/// Gets or sets the padding placed between the border of the control and its content.
///
diff --git a/src/Avalonia.Controls/TextBlock.cs b/src/Avalonia.Controls/TextBlock.cs
index 7387235a23..c21b8c7cdc 100644
--- a/src/Avalonia.Controls/TextBlock.cs
+++ b/src/Avalonia.Controls/TextBlock.cs
@@ -97,11 +97,13 @@ namespace Avalonia.Controls
///
/// Defines the property.
///
- public static readonly AttachedProperty LetterSpacingProperty =
- AvaloniaProperty.RegisterAttached(
- nameof(LetterSpacing),
- 0,
- inherits: true);
+ ///
+ /// This property uses to share the same
+ /// definition as , ensuring consistent behavior across text
+ /// elements and templated controls.
+ ///
+ public static readonly StyledProperty LetterSpacingProperty =
+ TextElement.LetterSpacingProperty.AddOwner();
///
/// Defines the property.
diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs
index 33cfddc4a1..b501722676 100644
--- a/src/Avalonia.Controls/TextBox.cs
+++ b/src/Avalonia.Controls/TextBox.cs
@@ -180,12 +180,6 @@ namespace Avalonia.Controls
public static readonly StyledProperty LineHeightProperty =
TextBlock.LineHeightProperty.AddOwner(new(defaultValue: double.NaN));
- ///
- /// Defines see property.
- ///
- public static readonly StyledProperty LetterSpacingProperty =
- TextBlock.LetterSpacingProperty.AddOwner();
-
///
/// Defines the property
///
@@ -570,15 +564,6 @@ namespace Avalonia.Controls
set => SetValue(MinLinesProperty, value);
}
- ///
- /// Gets or sets the spacing between characters
- ///
- public double LetterSpacing
- {
- get => GetValue(LetterSpacingProperty);
- set => SetValue(LetterSpacingProperty, value);
- }
-
///
/// Gets or sets the line height.
///
diff --git a/src/Avalonia.Themes.Fluent/Controls/Label.xaml b/src/Avalonia.Themes.Fluent/Controls/Label.xaml
index 3271349f22..daf38c2829 100644
--- a/src/Avalonia.Themes.Fluent/Controls/Label.xaml
+++ b/src/Avalonia.Themes.Fluent/Controls/Label.xaml
@@ -15,7 +15,7 @@
Content="{TemplateBinding Content}"
Padding="{TemplateBinding Padding}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
- HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/>
+ HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" />
diff --git a/src/Avalonia.Themes.Fluent/Controls/ToolTip.xaml b/src/Avalonia.Themes.Fluent/Controls/ToolTip.xaml
index b2fcfc7ddf..b3120301cb 100644
--- a/src/Avalonia.Themes.Fluent/Controls/ToolTip.xaml
+++ b/src/Avalonia.Themes.Fluent/Controls/ToolTip.xaml
@@ -46,6 +46,7 @@
MaxWidth="{TemplateBinding MaxWidth}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
+ TextBlock.LetterSpacing="{TemplateBinding LetterSpacing}"
TextBlock.TextWrapping="Wrap"/>
diff --git a/tests/Avalonia.Controls.UnitTests/ButtonTests.cs b/tests/Avalonia.Controls.UnitTests/ButtonTests.cs
index 45bd69c18a..ac6dd42fd3 100644
--- a/tests/Avalonia.Controls.UnitTests/ButtonTests.cs
+++ b/tests/Avalonia.Controls.UnitTests/ButtonTests.cs
@@ -619,6 +619,140 @@ namespace Avalonia.Controls.UnitTests
+ [Fact]
+ public void Button_LetterSpacing_Default_Value_Is_Zero()
+ {
+ var button = new Button();
+ Assert.Equal(0, button.LetterSpacing);
+ }
+
+ [Fact]
+ public void Button_LetterSpacing_Can_Be_Set_And_Retrieved()
+ {
+ var button = new Button { LetterSpacing = 2.5 };
+ Assert.Equal(2.5, button.LetterSpacing);
+ }
+
+ [Fact]
+ public void Button_LetterSpacing_Can_Be_Set_To_Negative_Value()
+ {
+ var button = new Button { LetterSpacing = -1.5 };
+ Assert.Equal(-1.5, button.LetterSpacing);
+ }
+
+ [Fact]
+ public void Button_LetterSpacing_Can_Be_Set_To_Zero()
+ {
+ var button = new Button { LetterSpacing = 5.0 };
+ button.LetterSpacing = 0;
+ Assert.Equal(0, button.LetterSpacing);
+ }
+
+ [Fact]
+ public void Button_LetterSpacing_Propagates_To_ContentPresenter()
+ {
+ using (UnitTestApplication.Start(TestServices.StyledWindow))
+ {
+ var button = new Button
+ {
+ Content = "Test",
+ LetterSpacing = 3.0
+ };
+ var root = new TestRoot { Child = button };
+
+ button.ApplyTemplate();
+
+ var presenter = button.Presenter;
+ Assert.NotNull(presenter);
+ Assert.Equal(3.0, presenter.LetterSpacing);
+ }
+ }
+
+ [Fact]
+ public void Button_LetterSpacing_Updates_ContentPresenter_When_Changed()
+ {
+ using (UnitTestApplication.Start(TestServices.StyledWindow))
+ {
+ var button = new Button
+ {
+ Content = "Test",
+ LetterSpacing = 1.0
+ };
+ var root = new TestRoot { Child = button };
+
+ button.ApplyTemplate();
+ var presenter = button.Presenter;
+
+ button.LetterSpacing = 5.0;
+
+ Assert.Equal(5.0, presenter.LetterSpacing);
+ }
+ }
+
+ [Fact]
+ public void Button_LetterSpacing_Works_With_Large_Values()
+ {
+ var button = new Button { LetterSpacing = 100.0 };
+ Assert.Equal(100.0, button.LetterSpacing);
+ }
+
+ [Fact]
+ public void Button_LetterSpacing_Property_Inherits_Through_Visual_Tree()
+ {
+ using (UnitTestApplication.Start(TestServices.StyledWindow))
+ {
+ var button = new Button
+ {
+ Content = "Test",
+ LetterSpacing = 2.0
+ };
+ var root = new TestRoot { Child = button };
+
+ button.ApplyTemplate();
+ button.Presenter?.UpdateChild();
+
+ // Verify the property value is accessible on the presenter
+ var presenter = button.Presenter;
+ Assert.NotNull(presenter);
+ Assert.Equal(2.0, presenter.LetterSpacing);
+ }
+ }
+
+ [Fact]
+ public void Button_LetterSpacing_Affects_TextBlock_Child_In_ContentPresenter()
+ {
+ using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface))
+ {
+ var button = new Button
+ {
+ Content = "Test Text",
+ LetterSpacing = 3.5
+ };
+ var root = new TestRoot { Child = button };
+
+ button.ApplyTemplate();
+ button.Presenter?.UpdateChild();
+
+ // Find the TextBlock that was created by ContentPresenter
+ var presenter = button.Presenter;
+ Assert.NotNull(presenter);
+
+ var textBlock = presenter.Child as TextBlock;
+ Assert.NotNull(textBlock);
+
+ // Verify LetterSpacing inherited to the TextBlock
+ Assert.Equal(3.5, textBlock.LetterSpacing);
+
+ // Force a measure to create TextLayout
+ textBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
+
+ // Verify the TextLayout actually has the LetterSpacing value
+ var textLayout = textBlock.TextLayout;
+ Assert.NotNull(textLayout);
+ Assert.Equal(3.5, textLayout.LetterSpacing);
+ }
+ }
+
private class TestTopLevel : TopLevel
{
private readonly ILayoutManager _layoutManager;
diff --git a/tests/Avalonia.Controls.UnitTests/CheckBoxTests.cs b/tests/Avalonia.Controls.UnitTests/CheckBoxTests.cs
new file mode 100644
index 0000000000..5ae8a2e9c3
--- /dev/null
+++ b/tests/Avalonia.Controls.UnitTests/CheckBoxTests.cs
@@ -0,0 +1,37 @@
+using Avalonia.UnitTests;
+using Xunit;
+
+namespace Avalonia.Controls.UnitTests
+{
+ public class CheckBoxTests : ScopedTestBase
+ {
+ [Fact]
+ public void CheckBox_LetterSpacing_Default_Value_Is_Zero()
+ {
+ var checkBox = new CheckBox();
+ Assert.Equal(0, checkBox.LetterSpacing);
+ }
+
+ [Fact]
+ public void CheckBox_LetterSpacing_Can_Be_Set_And_Retrieved()
+ {
+ var checkBox = new CheckBox { LetterSpacing = 2.5 };
+ Assert.Equal(2.5, checkBox.LetterSpacing);
+ }
+
+ [Fact]
+ public void CheckBox_LetterSpacing_Inherits_From_TemplatedControl()
+ {
+ var checkBox = new CheckBox { LetterSpacing = 3.0 };
+ // LetterSpacing is inherited from TemplatedControl
+ Assert.Equal(3.0, checkBox.LetterSpacing);
+ }
+
+ [Fact]
+ public void CheckBox_LetterSpacing_Can_Be_Negative()
+ {
+ var checkBox = new CheckBox { LetterSpacing = -1.5 };
+ Assert.Equal(-1.5, checkBox.LetterSpacing);
+ }
+ }
+}
diff --git a/tests/Avalonia.Controls.UnitTests/LabelTests.cs b/tests/Avalonia.Controls.UnitTests/LabelTests.cs
new file mode 100644
index 0000000000..7fb1e66d6c
--- /dev/null
+++ b/tests/Avalonia.Controls.UnitTests/LabelTests.cs
@@ -0,0 +1,37 @@
+using Avalonia.UnitTests;
+using Xunit;
+
+namespace Avalonia.Controls.UnitTests
+{
+ public class LabelTests : ScopedTestBase
+ {
+ [Fact]
+ public void Label_LetterSpacing_Default_Value_Is_Zero()
+ {
+ var label = new Label();
+ Assert.Equal(0, label.LetterSpacing);
+ }
+
+ [Fact]
+ public void Label_LetterSpacing_Can_Be_Set_And_Retrieved()
+ {
+ var label = new Label { LetterSpacing = 2.5 };
+ Assert.Equal(2.5, label.LetterSpacing);
+ }
+
+ [Fact]
+ public void Label_LetterSpacing_Inherits_From_TemplatedControl()
+ {
+ var label = new Label { LetterSpacing = 3.0 };
+ // LetterSpacing is inherited from TemplatedControl
+ Assert.Equal(3.0, label.LetterSpacing);
+ }
+
+ [Fact]
+ public void Label_LetterSpacing_Can_Be_Negative()
+ {
+ var label = new Label { LetterSpacing = -1.5 };
+ Assert.Equal(-1.5, label.LetterSpacing);
+ }
+ }
+}
diff --git a/tests/Avalonia.Controls.UnitTests/Presenters/ContentPresenterTests_Standalone.cs b/tests/Avalonia.Controls.UnitTests/Presenters/ContentPresenterTests_Standalone.cs
index 53887a90cd..3ec4e52d8b 100644
--- a/tests/Avalonia.Controls.UnitTests/Presenters/ContentPresenterTests_Standalone.cs
+++ b/tests/Avalonia.Controls.UnitTests/Presenters/ContentPresenterTests_Standalone.cs
@@ -12,6 +12,7 @@ using Xunit;
using Avalonia.Rendering;
using Avalonia.Media;
using Avalonia.Data;
+using Avalonia.Controls.Documents;
namespace Avalonia.Controls.UnitTests.Presenters
{
@@ -333,5 +334,75 @@ namespace Avalonia.Controls.UnitTests.Presenters
Assert.NotNull(target.Child);
}
+
+ [Fact]
+ public void ContentPresenter_LetterSpacing_Default_Value_Is_Zero()
+ {
+ var presenter = new ContentPresenter();
+ Assert.Equal(0, presenter.LetterSpacing);
+ }
+
+ [Fact]
+ public void ContentPresenter_LetterSpacing_Can_Be_Set_And_Retrieved()
+ {
+ var presenter = new ContentPresenter { LetterSpacing = 3.5 };
+ Assert.Equal(3.5, presenter.LetterSpacing);
+ }
+
+ [Fact]
+ public void ContentPresenter_LetterSpacing_Can_Be_Negative()
+ {
+ var presenter = new ContentPresenter { LetterSpacing = -2.0 };
+ Assert.Equal(-2.0, presenter.LetterSpacing);
+ }
+
+ [Fact]
+ public void ContentPresenter_LetterSpacing_Propagates_To_TextBlock_Child()
+ {
+ using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface))
+ {
+ var presenter = new ContentPresenter
+ {
+ Content = "Test Content",
+ LetterSpacing = 4.0
+ };
+ var root = new TestRoot { Child = presenter };
+
+ presenter.UpdateChild();
+
+ var textBlock = presenter.Child as TextBlock;
+ Assert.NotNull(textBlock);
+ Assert.Equal(4.0, textBlock.LetterSpacing);
+ }
+ }
+
+ [Fact]
+ public void ContentPresenter_LetterSpacing_Updates_TextBlock_When_Changed()
+ {
+ using (UnitTestApplication.Start(TestServices.MockPlatformRenderInterface))
+ {
+ var presenter = new ContentPresenter
+ {
+ Content = "Test Content",
+ LetterSpacing = 1.0
+ };
+ var root = new TestRoot { Child = presenter };
+
+ presenter.UpdateChild();
+ var textBlock = presenter.Child as TextBlock;
+
+ presenter.LetterSpacing = 6.0;
+
+ Assert.NotNull(textBlock);
+ Assert.Equal(6.0, textBlock.LetterSpacing);
+ }
+ }
+
+ [Fact]
+ public void ContentPresenter_LetterSpacing_Property_Inherits_From_TextBlock()
+ {
+ // Verify that ContentPresenter's LetterSpacing uses the TextElement letter spacing definition
+ Assert.Same(TextElement.LetterSpacingProperty, ContentPresenter.LetterSpacingProperty);
+ }
}
}
diff --git a/tests/Avalonia.Controls.UnitTests/Primitives/TemplatedControlTests.cs b/tests/Avalonia.Controls.UnitTests/Primitives/TemplatedControlTests.cs
index 0d76484a34..9656b6496e 100644
--- a/tests/Avalonia.Controls.UnitTests/Primitives/TemplatedControlTests.cs
+++ b/tests/Avalonia.Controls.UnitTests/Primitives/TemplatedControlTests.cs
@@ -11,6 +11,7 @@ using Avalonia.UnitTests;
using Avalonia.VisualTree;
using Xunit;
using Avalonia.Media;
+using Avalonia.Controls.Documents;
namespace Avalonia.Controls.UnitTests.Primitives
{
@@ -597,5 +598,52 @@ namespace Avalonia.Controls.UnitTests.Primitives
return result;
}
+
+ [Fact]
+ public void TemplatedControl_LetterSpacing_Default_Value_Is_Zero()
+ {
+ var target = new TestTemplatedControl();
+ Assert.Equal(0, target.LetterSpacing);
+ }
+
+ [Fact]
+ public void TemplatedControl_LetterSpacing_Uses_TextElement_Property()
+ {
+ Assert.Same(TextElement.LetterSpacingProperty, TemplatedControl.LetterSpacingProperty);
+ }
+
+ [Fact]
+ public void TemplatedControl_LetterSpacing_Can_Be_Set_And_Retrieved()
+ {
+ var target = new TestTemplatedControl { LetterSpacing = 2.5 };
+ Assert.Equal(2.5, target.LetterSpacing);
+ }
+
+ [Fact]
+ public void TemplatedControl_LetterSpacing_Can_Be_Negative()
+ {
+ var target = new TestTemplatedControl { LetterSpacing = -1.5 };
+ Assert.Equal(-1.5, target.LetterSpacing);
+ }
+
+ [Fact]
+ public void TemplatedControl_LetterSpacing_Inherits_To_ContentPresenter()
+ {
+ using (UnitTestApplication.Start(TestServices.StyledWindow))
+ {
+ var target = new ContentControl
+ {
+ LetterSpacing = 3.0,
+ Content = "Test",
+ };
+ var root = new TestRoot { Child = target };
+
+ target.ApplyTemplate();
+
+ var presenter = target.Presenter;
+ Assert.NotNull(presenter);
+ Assert.Equal(3.0, presenter.LetterSpacing);
+ }
+ }
}
}
diff --git a/tests/Avalonia.Controls.UnitTests/RadioButtonTests.cs b/tests/Avalonia.Controls.UnitTests/RadioButtonTests.cs
index 9d6447d7e0..8ea464e0f4 100644
--- a/tests/Avalonia.Controls.UnitTests/RadioButtonTests.cs
+++ b/tests/Avalonia.Controls.UnitTests/RadioButtonTests.cs
@@ -106,8 +106,28 @@ namespace Avalonia.Controls.UnitTests
Assert.False(radioButton2.IsChecked);
Assert.True(radioButton3.IsChecked);
Assert.False(radioButton4.IsChecked);
+ }
+
+ [Fact]
+ public void RadioButton_LetterSpacing_Default_Value_Is_Zero()
+ {
+ var radioButton = new RadioButton();
+ Assert.Equal(0, radioButton.LetterSpacing);
+ }
+ [Fact]
+ public void RadioButton_LetterSpacing_Can_Be_Set_And_Retrieved()
+ {
+ var radioButton = new RadioButton { LetterSpacing = 2.5 };
+ Assert.Equal(2.5, radioButton.LetterSpacing);
+ }
+ [Fact]
+ public void RadioButton_LetterSpacing_Inherits_From_TemplatedControl()
+ {
+ var radioButton = new RadioButton { LetterSpacing = 3.0 };
+ // LetterSpacing is inherited from TemplatedControl
+ Assert.Equal(3.0, radioButton.LetterSpacing);
}
}
}
diff --git a/tests/Avalonia.Controls.UnitTests/TextBlockTests.cs b/tests/Avalonia.Controls.UnitTests/TextBlockTests.cs
index 97e5d85d92..63db6cfcb9 100644
--- a/tests/Avalonia.Controls.UnitTests/TextBlockTests.cs
+++ b/tests/Avalonia.Controls.UnitTests/TextBlockTests.cs
@@ -28,6 +28,12 @@ namespace Avalonia.Controls.UnitTests
Assert.Equal(null, textBlock.Text);
}
+ [Fact]
+ public void LetterSpacing_Property_Uses_TextElement_Definition()
+ {
+ Assert.Same(TextElement.LetterSpacingProperty, TextBlock.LetterSpacingProperty);
+ }
+
[Fact]
public void Calling_Measure_Should_Update_TextLayout()
{