AvaloniaUI / AvaloniaVS

Visual Studio Extension for Avalonia
MIT License
431 stars 83 forks source link

Add custom prefix into mc:Ignorable will make related marks not work in designer. #349

Open Flithor opened 1 year ago

Flithor commented 1 year ago

Describe the bug

Look at code. Remove ph in mc:Ignorable will make PlaceHolder.BackGround works, but add will make it not work.

btw: d:Background not work.

To Reproduce

using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;

namespace MyNamespace
{
    namespace PlaceHolder
    {
        public static class PlaceHolder
        {
            public static readonly AttachedProperty<IBrush> BackGroundProperty = AvaloniaProperty.RegisterAttached<IControl, IControl, IBrush>(
                "BackGround");

            /// <summary>
            /// Accessor for Attached property <see cref="BackGroundProperty"/>.
            /// </summary>
            public static void SetBackGround(AvaloniaObject element, IBrush value)
            {
                if (Design.IsDesignMode)
                {
                    var bg = element.GetType()!.GetProperty("Background", returnType: typeof(IBrush));
                    if (bg != null)
                        bg.SetValue(element, newValue);
                }
                element.SetValue(BackGroundProperty, value);
            }

            /// <summary>
            /// Accessor for Attached property <see cref="BackGroundProperty"/>.
            /// </summary>
            public static IBrush GetBackGround(AvaloniaObject element)
            {
                return element.GetValue(BackGroundProperty);
            }
        }
    }
}
<UserControl balabalabala
             xmlns:ph="clr-namespace:MyNamespace.PlaceHolder"
             d:DesignHeight="600"
             d:DesignWidth="1200"
             ph:PlaceHolder.BackGround="#77FF0000" 
             mc:Ignorable="d ph">

AvaloniaVS plugin version

0.10.18.4

Avalonia version

0.10.21

Visual Studio version

17.4.4

Relevant log output

Nolog

Additional context

No response