Why "TextWrapping" automatically add to XAML when TextBox inserted

c#, wpf, wpf-controls, xaml

Solution

What you want is the DefaultInitializer that defines what defaults are set when dragging from the ToolBox onto the design view.

[Feature(typeof(myDefaults))]
public partial class UserControl1 : UserControl
{
    public UserControl1()
    {
        InitializeComponent();
    }

    public class myDefaults : DefaultInitializer
    {
        public override void InitializeDefaults(ModelItem item)
        {
            item.Name = "test";
        }
    }
}

Then dragging and dropping this control on the form results in

<local:UserControl1 x:Name="test" Width="100"/>

Problem

After Drag/Drop some control like TextBox in a WPF Window, you can see below line in XAML ``` <TextBox ... TextWrapping="Wrap" Text="TextBox" /> ``` These properties automatically insert to XAML! Just some special property inserted in XAML. Questions: - Why just these special properties (like `TextWrapping` or `Text` for TextBox) automatically add in XAML? (Is there a kind of Attribute for this)? - I want to inherit a class from TextBox and prevent of automatic insertion of `TextWrapping` property. Is it Possible? (Is there a kind of Attribute for this)? - Is there a solution, to select some properties for automatic inserted in XAML, in design mode (like this `TextWrapping` TextBox)?

Original source