@ -15,13 +15,55 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions.Initializers
{
{
public override void InitializeDefaults ( DesignItem item )
public override void InitializeDefaults ( DesignItem item )
{
{
DesignItemProperty contentProperty = item . Properties [ "Content" ] ;
//Not every Content Control can have a text as Content (e.g. ZoomBox of WPF Toolkit)
if ( contentProperty . ValueOnInstance = = null ) {
if ( item . Component is Button )
contentProperty . SetValue ( item . ComponentType . Name ) ;
{
DesignItemProperty contentProperty = item . Properties [ "Content" ] ;
if ( contentProperty . ValueOnInstance = = null )
{
contentProperty . SetValue ( item . ComponentType . Name ) ;
}
}
}
DesignItemProperty verticalAlignmentProperty = item . Properties [ "VerticalAlignment" ] ;
if ( verticalAlignmentProperty . ValueOnInstance = = null )
{
verticalAlignmentProperty . SetValue ( VerticalAlignment . Center ) ;
}
DesignItemProperty horizontalAlignmentProperty = item . Properties [ "HorizontalAlignment" ] ;
if ( horizontalAlignmentProperty . ValueOnInstance = = null )
{
horizontalAlignmentProperty . SetValue ( HorizontalAlignment . Center ) ;
}
}
}
}
}
[ExtensionFor(typeof(TextBlock))]
public class TextBlockInitializer : DefaultInitializer
{
public override void InitializeDefaults ( DesignItem item )
{
DesignItemProperty textProperty = item . Properties [ "Text" ] ;
if ( textProperty . ValueOnInstance = = null | | textProperty . ValueOnInstance . ToString ( ) = = "" )
{
textProperty . SetValue ( item . ComponentType . Name ) ;
}
DesignItemProperty verticalAlignmentProperty = item . Properties [ "VerticalAlignment" ] ;
if ( verticalAlignmentProperty . ValueOnInstance = = null )
{
verticalAlignmentProperty . SetValue ( VerticalAlignment . Center ) ;
}
DesignItemProperty horizontalAlignmentProperty = item . Properties [ "HorizontalAlignment" ] ;
if ( horizontalAlignmentProperty . ValueOnInstance = = null )
{
horizontalAlignmentProperty . SetValue ( HorizontalAlignment . Center ) ;
}
}
}
[ExtensionFor(typeof(HeaderedContentControl), OverrideExtension = typeof(ContentControlInitializer))]
[ExtensionFor(typeof(HeaderedContentControl), OverrideExtension = typeof(ContentControlInitializer))]
public class HeaderedContentControlInitializer : DefaultInitializer
public class HeaderedContentControlInitializer : DefaultInitializer
{
{