Set dependency property in xaml

I have a custom UserControl that provides the following dependency property: CanEdit. The property was created using the fragment, and the generated code:

#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

I am trying to set this property to True in the parent UserControl, for example:

<RequisitionItem CanEdit="True" />

but the property remains False. Why is this?

+3
source share
1 answer

Assuming you mean that children have a property still set to false, this sounds like an inheritance issue.

Check out this page for inheritance of values ; there is one section called Making a Custom Inheritable Property , which may provide some help.

0
source

All Articles