|
|
|
@ -40,11 +40,6 @@ namespace Avalonia.Controls |
|
|
|
public static readonly StyledProperty<VerticalAlignment> VerticalContentAlignmentProperty = |
|
|
|
AvaloniaProperty.Register<ContentControl, VerticalAlignment>(nameof(VerticalContentAlignment)); |
|
|
|
|
|
|
|
static ContentControl() |
|
|
|
{ |
|
|
|
ContentProperty.Changed.AddClassHandler<ContentControl>((x, e) => x.ContentChanged(e)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the content to display.
|
|
|
|
/// </summary>
|
|
|
|
@ -95,22 +90,20 @@ namespace Avalonia.Controls |
|
|
|
/// <inheritdoc/>
|
|
|
|
IAvaloniaList<ILogical> IContentPresenterHost.LogicalChildren => LogicalChildren; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Determine whether <see cref="ContentControl"/> manage his LogicalChildren
|
|
|
|
///(default behavior) himself, or leaves the management to the inherited control.
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// The default value is false, So the <see cref="ContentControl"/> manages itself,
|
|
|
|
/// if you want to bypass this behavior and manage LogicalChildren yourself, set
|
|
|
|
/// the <see cref="BypassLogicalChildrenManagement"/> to true.
|
|
|
|
/// </remarks>
|
|
|
|
protected virtual bool BypassLogicalChildrenManagement => false; |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
bool IContentPresenterHost.RegisterContentPresenter(ContentPresenter presenter) |
|
|
|
{ |
|
|
|
return RegisterContentPresenter(presenter); |
|
|
|
} |
|
|
|
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) |
|
|
|
{ |
|
|
|
base.OnPropertyChanged(change); |
|
|
|
|
|
|
|
if (change.Property == ContentProperty) |
|
|
|
{ |
|
|
|
ContentChanged(change); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Called when an <see cref="ContentPresenter"/> is registered with the control.
|
|
|
|
@ -129,11 +122,6 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
private void ContentChanged(AvaloniaPropertyChangedEventArgs e) |
|
|
|
{ |
|
|
|
if (BypassLogicalChildrenManagement) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (e.OldValue is ILogical oldChild) |
|
|
|
{ |
|
|
|
LogicalChildren.Remove(oldChild); |
|
|
|
|