我在 Windows 工作流中构建了许多自定义活动,我需要添加一个 DependencyProperty,它可以列出该属性的许多值,然后用户可以在使用活动时选择这些值。
例如真或假。
我知道如何简单地使用 PropertyMetadata 传递默认值,并假设我现在必须传递一个列表/类 PropertyMetadata?
有没有人已经有一个如何做到这一点的例子?
(下面的示例代码)
public static DependencyProperty TestProperty = DependencyProperty.Register("Test", typeof(string), typeof(CheckActivity), new PropertyMetadata("True"));
/// <summary>
/// Dependency property for 'TestProperty'
/// </summary>
[DescriptionAttribute("Whether a True/False entry is required")]
[CategoryAttribute("Settings")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public string Type
{
get
{
return ((string)(base.GetValue(CheckActivity.TestProperty)));
}
set
{
base.SetValue(CheckActivity.TestProperty, value);
}
}