You can get pretty flexible design time behavior with a combination of System.ComponentModel
attributes and DependencyProperty
metadata. The PropertyMetadata
class has a constructor that takes a default value:
[Category("MyCustomCategory")]
public string MyCustomProperty
{
get { return GetValue(MyCustomPropertyProperty).ToString(); }
set { SetValue(MyCustomPropertyProperty, value); }
}
public static DependencyProperty MyCustomPropertyProperty =
DependencyProperty
.Register(
"MyCustomProperty",
typeof(string),
typeof(MyCustomUserControl),
new PropertyMetadata("My default value")); // <--- default value
