Skip to content

Proposal: Tree view node .Tag() method/property #10384

@szaaamerik

Description

@szaaamerik

Summary

Adding a ".Tag()" method/property to the TreeViewNode's. This way we can identify them a different way than just the content.

Rationale

Consider this: when you’re building a c++ app without XAML (while this is "not preferred" by most, my team does this), you end up writing A LOT of messy code just to link data to nodes. Think something like: either write a lot of wrappers for stuff (example concept shown below) or use very unique content for each tree view node (e.g. "1. This is bob's tree view node" "2. This is Angie's tree view node"). Without .Tag(), we’re stuck reinventing the wheel for something every other UI control already does. Why?

Earlier mentioned "Wrappers":

struct TSubTreeViewNodeWrapper {
    std::wstring tag;
    TreeViewNode& node;
}; 

struct TRootTreeViewNodeWrapper {
    std::wstring tag;
    TreeViewNode& node;
    std::vector<TSubTreeViewNodeWrapper> children;
};

Scope

Capability Priority
Allow attaching an IInspectable (Object for C#? -- don't know, don't code in it) to a TreeViewNode without extra wrappers Must
Include a TagChanged event to notify when the tag updates Could
Provide basic thread safety for tag access (e.g., std::lock/SRWLock) Should

Important Notes

Example usage:

TreeViewNode node;  
node.Tag(myCustomData); // Set
IInspectable data = node.Tag();  // Retrieve

API proposal:

Add a "Tag" property to the TreeViewNode class. This keeps code clean and avoids hacks like unique content or maintaining separate wrappers.

Open Questions

None for now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions