Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DiagramCustomGetEditableItemPropertiesCacheKeyEventArgs.CacheKey Property

Gets or sets the cache key assigned to the edited diagram item.

Namespace: DevExpress.Xpf.Diagram

Assembly: DevExpress.Xpf.Diagram.v24.2.dll

NuGet Package: DevExpress.Wpf.Diagram

#Declaration

public object CacheKey { get; set; }

#Property Value

Type Description
Object

An object that is the cache key associated with the edited item.

#Remarks

The following example demonstrates a custom shape that derives from the DiagramShape. When the ShowInfo property value is set to true, the property grid displays the Info property.

 //DiagramShapeEx.cs
public class DiagramShapeEx : DiagramShape {
    //the NotifyParentProperty attribute is used to notify the DiagramControl
    //that the ShowInfo value has changed.
    [NotifyParentProperty(true)]
    public bool ShowInfo {
        get;
        set;
    }
    public string Info {
        get;
        set;
    }
}

//...

void diagramControl1_CustomGetEditableItemProperties(object sender, DiagramCustomGetEditableItemPropertiesEventArgs e) {
    DiagramShapeEx shapeEx = e.Item as DiagramShapeEx;
    if (shapeEx != null) {
        e.Properties.Add(TypeDescriptor.GetProperties(typeof(DiagramShapeEx))["ShowInfo"]);
        if (shapeEx.ShowInfo)
            e.Properties.Add(TypeDescriptor.GetProperties(typeof(DiagramShapeEx))["Info"]);
    }
}

void diagramControl1_CustomGetEditableItemPropertiesCacheKey(object sender, DiagramCustomGetEditableItemPropertiesCacheKeyEventArgs e) {
    if (e.Item is DiagramShapeEx)
        e.CacheKey = Tuple.Create(typeof(DiagramShapeEx), ((DiagramShapeEx)e.Item).ShowInfo);
}

Tip

If you have a reasonable number of shapes on the canvas, you can set the e.CacheKey to null without affecting the performance.

See Also