开发者

set a dependency property in xaml

开发者 https://www.devze.com 2023-03-02 10:51 出处:网络
I have a custom UserControl which exposes the following dependency property: CanEdit. The property was created using a snippet and the generated code is:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消