Skip to content

Commit f61bcc3

Browse files
authored
Add Content attribute to ContentPresenter (#21997)
* Add Content attribute to ContentPresenter * Add ContentPresenter default content property test
1 parent 7f36978 commit f61bcc3

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/Avalonia.Controls/Presenters/ContentPresenter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ public Control? Child
364364
/// <summary>
365365
/// Gets or sets the content to be displayed by the presenter.
366366
/// </summary>
367+
[Content]
367368
[DependsOn(nameof(ContentTemplate))]
368369
public object? Content
369370
{

tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BasicTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ public void Default_Content_Property_Is_Set()
4242
Assert.Equal("Foo", target.Content);
4343
}
4444

45+
[Fact]
46+
public void ContentPresenter_Default_Content_Property_Is_Set()
47+
{
48+
var xaml = @"<ContentPresenter xmlns='https://github.com/avaloniaui'>Foo</ContentPresenter>";
49+
50+
var target = AvaloniaRuntimeXamlLoader.Parse<ContentPresenter>(xaml);
51+
52+
Assert.NotNull(target);
53+
Assert.Equal("Foo", target.Content);
54+
}
55+
4556
[Fact]
4657
public void Attached_Property_Is_Set()
4758
{

0 commit comments

Comments
 (0)