Skip to content

[TreeView] weird selection behavior when I try to remove an item #10368

Closed Answered by YkTru
YkTru asked this question in Q&A
Discussion options

You must be logged in to vote

@miloush It works! Thank you so much for your guidance. Those "little" bug can drive crazy sometimes! I also had some help with gpt feeding it with our discussions.

Video_2025-02-01_214221.mp4

[Solution]: I made a custom treeview where I override OnItemsChanged:

public class CustomTreeView : TreeView
{
        // (...)
        protected override bool IsItemItsOwnContainerOverride(object item)
        {
            return item is CustomTreeViewItem;
        }

        protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Remove ||
                e.Action == NotifyCollectionChangedAction.Reset)

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@YkTru
Comment options

Comment options

You must be logged in to vote
3 replies
@miloush
Comment options

miloush Feb 1, 2025
Collaborator

@YkTru
Comment options

@miloush
Comment options

miloush Feb 2, 2025
Collaborator

Comment options

You must be logged in to vote
0 replies
Answer selected by YkTru
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants