-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to implement a TreeView with node changes? #230
Conversation
43e97a4
to
5d8f500
Compare
5d8f500
to
d144d86
Compare
member this.Name = name | ||
member this.Children = children | ||
|
||
module NodeView = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@h0lg I have not used INotifyPropertyChanged
with Fabulous in the past(might be possible, but not sure if fits with the Fabulous state runners.). I normally create a simple MVU component. See my last commit and improve the way you need :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edgarfgp You may be right. I have seen things like the often used AvaloniaPropertyChangedEventArgs
in the Avalonia source that suggest there may be a custom property change implementation in play, but haven't looked into it.
Thank you - I was able to understand and turn your approach into a working solution within minutes!
I'll try it out in a slightly more complex scenario with a filtered tree.
If I understand correctly, the trick is to keep the messages encapsulated within the NodeView
Component so that the host program doesn't have to re-render the TreeView
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, having separate component is needed here to track and update the node state and also to prevent the re-rendering of the widget tree.
cf4d072
to
2b66c11
Compare
@h0lg This is already a good improvement for the samples. I am happy to accept it as it is. You can follow up in a separate PR if that works for you ? |
@edgarfgp My intent was to convert this into a separate example and keep the existing one untouched - to have at least one TreeView example remaining that's really basic. I find that helpful as an introduction. There's also some unused code that begs the question. Maybe it just needs some comments like |
Thanks, that would be useful.
Yeah. Let's add a |
2b66c11
to
7c1273a
Compare
… collapses on change
… replacement - node expansion is preserved, but click count in UI is not updated
…nged events - without effect
…fferent TreeViews
909b00c
to
7826232
Compare
@edgarfgp I've instead found a use for the selected model node by adding a
done - ready for a review and merge. Thanks a bunch! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all this improvements. Love your contributions 👍
Hey Fabulous Avalonia team!
On this branch I'm trying to extend the existing
TreeViewPage
example with some interactivity and as an example chose to count clicks per node and display the count while also preserving the node expansion of the tree. I'm failing with one or the other in different implementations.Could you please have a look at it and share your thoughts or suggest changes? You'll find my different attempts in my commit history, what works and doesn't with each in the respective message.
Thanks a bunch!