This documentation is archived and is not being maintained.

DefaultInitializer Class

Used to configure a new object in the designer.


Namespace:  Microsoft.Windows.Design.Model
Assembly:  Microsoft.Windows.Design.Interaction (in Microsoft.Windows.Design.Interaction.dll)

public abstract class DefaultInitializer : FeatureProvider

The DefaultInitializer type exposes the following members.

Protected methodDefaultInitializerInitializes a new instance of the DefaultInitializer class.

Public methodEqualsDetermines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeDefaults(ModelItem)Initializes default values for the specified item.
Public methodInitializeDefaults(ModelItem, EditingContext)Initializes default values for the specified item using the provided editing context.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

The DefaultInitializer extension is invoked when the user adds an object from the Toolbox to the design surface. Derive from the DefaultInitializer class to configure default initial values for your object. For example, you might add some default content to a button control or set a panel's width and height to a constant value, so that it does not collapse to zero size when it is added to the design surface. When created from the Toolbox, the element's property values appear in XAML view.


Do not set default initial values in an element's constructor. The designer may not call your constructor, and in this case your default initial values are not set at design time. Instead, use the DefaultInitializer class or the ClearValue method to set default initial values.

The following code example shows how to override the InitializeDefaults method to set the default value for a Button control's Content property to "Button".

using System;

using Microsoft.Windows.Design.Model;
using Microsoft.Windows.Design.Features;

namespace DemoControlLibrary.VisualStudio.Design
    public class DemoButton { }

    class ButtonDefaults : DefaultInitializer
        public override void InitializeDefaults(ModelItem item)

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.