Browse Source
Add Content attribute to ContentPresenter (#21997)
* Add Content attribute to ContentPresenter
* Add ContentPresenter default content property test
pull/22014/head
Yoyo
1 month ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
12 additions and
0 deletions
-
src/Avalonia.Controls/Presenters/ContentPresenter.cs
-
tests/Avalonia.Markup.Xaml.UnitTests/Xaml/BasicTests.cs
|
|
@ -364,6 +364,7 @@ namespace Avalonia.Controls.Presenters |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets or sets the content to be displayed by the presenter.
|
|
|
/// Gets or sets the content to be displayed by the presenter.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
|
|
|
[Content] |
|
|
[DependsOn(nameof(ContentTemplate))] |
|
|
[DependsOn(nameof(ContentTemplate))] |
|
|
public object? Content |
|
|
public object? Content |
|
|
{ |
|
|
{ |
|
|
|
|
|
@ -42,6 +42,17 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml |
|
|
Assert.Equal("Foo", target.Content); |
|
|
Assert.Equal("Foo", target.Content); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
public void ContentPresenter_Default_Content_Property_Is_Set() |
|
|
|
|
|
{ |
|
|
|
|
|
var xaml = @"<ContentPresenter xmlns='https://github.com/avaloniaui'>Foo</ContentPresenter>"; |
|
|
|
|
|
|
|
|
|
|
|
var target = AvaloniaRuntimeXamlLoader.Parse<ContentPresenter>(xaml); |
|
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(target); |
|
|
|
|
|
Assert.Equal("Foo", target.Content); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Attached_Property_Is_Set() |
|
|
public void Attached_Property_Is_Set() |
|
|
{ |
|
|
{ |
|
|
|