我有一个自定义的UserControl,它公开了以下依赖属性:CanEdit。该属性是使用代码段创建的,生成的代码如下:
#region CanEdit
/// <summary>
/// CanEdit Dependency Property
/// </summary>
public static readonly DependencyProperty CanEditProperty =
DependencyProperty.Register("CanEdit", typeof(bool), typeof(RequisitionItem),
new PropertyMetadata((bool)false));
/// <summary>
/// Gets or sets the CanEdit property. This dependency property
/// indicates ....
/// </summary>
public bool CanEdit {
get { return (bool)GetValue(CanEditProperty); }
set { SetValue(CanEditProperty, value); }
}
#endregion
我正在尝试在父UserControl上设置此属性为True,如下所示:
<RequisitionItem CanEdit="True" />
但是属性仍然保持为False。为什么呢?