Repository: AvaloniaUI/Avalonia
File: src/Avalonia.Controls/ContentControl.cs (C#)

Code before:
        /// <summary>
        /// Defines the <see cref="ContentTemplate"/> property.
        /// </summary>
        public static readonly StyledProperty<IDataTemplate?> ContentTemplateProperty =
            AvaloniaProperty.Register<ContentControl, IDataTemplate?>(nameof(ContentTemplate));

        /// <summary>
        /// Defines the <see cref="HorizontalContentAlignment"/> property.
        /// </summary>
        public static readonly StyledProperty<HorizontalAlignment> HorizontalContentAlignmentProperty =
            AvaloniaProperty.Register<ContentControl, HorizontalAlignment>(nameof(HorizontalContentAlignment));

        /// <summary>
        /// Defines the <see cref="VerticalContentAlignment"/> property.
        /// </summary>
        public static readonly StyledProperty<VerticalAlignment> VerticalContentAlignmentProperty =
            AvaloniaProperty.Register<ContentControl, VerticalAlignment>(nameof(VerticalContentAlignment));

        static ContentControl()
        {
            ContentProperty.Changed.AddClassHandler<ContentControl>((x, e) => x.ContentChanged(e));
            TemplateProperty.OverrideDefaultValue<ContentControl>(new FuncControlTemplate((c, ns) =>
            {
                var presenter = new ContentPresenter
                {
                    [~BackgroundProperty] = c.GetObservable(BackgroundProperty).ToBinding(),
                    [~BorderBrushProperty] = c.GetObservable(BorderBrushProperty).ToBinding(),
                    [~BorderThicknessProperty] = c.GetObservable(BorderThicknessProperty).ToBinding(),
                    [~CornerRadiusProperty] = c.GetObservable(CornerRadiusProperty).ToBinding(),
                    [~ContentTemplateProperty] = c.GetObservable(ContentTemplateProperty).ToBinding(),
                    [~ContentProperty] = c.GetObservable(ContentProperty).ToBinding(),
                    [~PaddingProperty] = c.GetObservable(PaddingProperty).ToBinding(),
                    [~VerticalContentAlignmentProperty] = c.GetObservable(VerticalContentAlignmentProperty).ToBinding(),
                    [~HorizontalContentAlignmentProperty] = c.GetObservable(HorizontalContentAlignmentProperty).ToBinding()
                };
                ns.Register("PART_ContentPresenter", presenter);
                return presenter;
            }));
        }

        /// <summary>
        /// Gets or sets the content to display.
        /// </summary>
        [Content]
        [DependsOn(nameof(ContentTemplate))]
        public object? Content
        {
            get { return GetValue(ContentProperty); }
            set { SetValue(ContentProperty, value); }
        }


Review comment (suggestion):
I'm not sure if this will be a problem, but I think this means that the subscriptions to the `ContentControl` properties will never be released. So if the default value is used, and then a template is supplied, the original default template subscriptions won't be removed.

Code after:

        /// <summary>
        /// Defines the <see cref="ContentTemplate"/> property.
        /// </summary>
        public static readonly StyledProperty<IDataTemplate?> ContentTemplateProperty =
            AvaloniaProperty.Register<ContentControl, IDataTemplate?>(nameof(ContentTemplate));

        /// <summary>
        /// Defines the <see cref="HorizontalContentAlignment"/> property.
        /// </summary>
        public static readonly StyledProperty<HorizontalAlignment> HorizontalContentAlignmentProperty =
            AvaloniaProperty.Register<ContentControl, HorizontalAlignment>(nameof(HorizontalContentAlignment));

        /// <summary>
        /// Defines the <see cref="VerticalContentAlignment"/> property.
        /// </summary>
        public static readonly StyledProperty<VerticalAlignment> VerticalContentAlignmentProperty =
            AvaloniaProperty.Register<ContentControl, VerticalAlignment>(nameof(VerticalContentAlignment));

        static ContentControl()
        {
            TemplateProperty.OverrideDefaultValue<ContentControl>(new FuncControlTemplate((_, ns) => new ContentPresenter
            {
                Name = "PART_ContentPresenter",
                [~BackgroundProperty] = new TemplateBinding(BackgroundProperty),
                [~BorderBrushProperty] = new TemplateBinding(BorderBrushProperty),
                [~BorderThicknessProperty] = new TemplateBinding(BorderThicknessProperty),
                [~CornerRadiusProperty] = new TemplateBinding(CornerRadiusProperty),
                [~ContentTemplateProperty] = new TemplateBinding(ContentTemplateProperty),
                [~ContentProperty] = new TemplateBinding(ContentProperty),
                [~PaddingProperty] = new TemplateBinding(PaddingProperty),
                [~VerticalContentAlignmentProperty] = new TemplateBinding(VerticalContentAlignmentProperty),
                [~HorizontalContentAlignmentProperty] = new TemplateBinding(HorizontalContentAlignmentProperty)
            }.RegisterInNameScope(ns)));
        }

        /// <summary>
        /// Gets or sets the content to display.
        /// </summary>
        [Content]
        [DependsOn(nameof(ContentTemplate))]
        public object? Content
        {
            get => GetValue(ContentProperty);
            set => SetValue(ContentProperty, value);
        }

        /// <summary>
        /// Gets or sets the data template used to display the content of the control.
        /// </summary>
        public IDataTemplate? ContentTemplate