I have a custom UserControl which exposes the following dependency property: CanEdit. The property was created using a snippet and the generated code is:
#region CanEdit
/// <summary>
/// CanEdit Dependency Property
/// </summary>
public static reado开发者_如何学Pythonnly 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
I'm trying to set this property to True on the parent UserControl, like this:
<RequisitionItem CanEdit="True" />
but the property stays False. Why is that?
Assuming that you mean the child items have the property still set to false this sounds like an inheritance issue.
See this page on value inheritance, there is one section called Making a Custom Property Inheritable, which might offer some help.
精彩评论