What WPF Treeview trigger happens after a user selects something?
In winforms treeviews have a trigger called AfterSelect that occurs...after the user selects something. It doesn't trigger if something is unselected, only if a new thing is selected.
In WPF, AfterSelect doesn't exist. i looked through then and found SelectedItemChanged but it triggers when something is unselected. This causes my program to error / crash because i am using the name of the selected item as part of a filepath search. Theres a lot of triggers and a lot of google to figure out what one triggers only after a user selects something, so i thought i would just make a post asking if anyone knows what trigger occurs only after a user selects something in a treeview.
55 Replies
then check if something is selected before doing whatever
also dont use the designer
it generates unreadable code that relies on margins for layout so you dont get responsiveness
"the designer"?
huh?
visual drag and drop thing
its called something designer
iirc
yeah visual designer
i uh, really only want to use a visual designer
using anything else is so awful and slow
slow?
it would take way longer for the same result
oh slow to develop
yes
also, im not sure what you mean by " margins for layout so you dont get responsiveness"
the designer is also not accurate, it can be off by few (or more than a few) pixels
whats unresponsive about it?
it means when you resize the window control dont move/scale like they should
i noticed this, it seems to only happen with WPF not with winforms
yeah
i assume i'll find an answer as to why at a later time and fix it
winforms desginer is fine
but current understanding is it has something to do with scaling and star mode
the answer is that its bad and microsoft doesnt update it anymore
so it will always be like this
but you shouldnt need it anyway
learning xaml will be super worth it
well, to my knowledge, there is no current visual builder thats better
once youre used it youll be faster than using the designer
i shopped around, found nothing just outdated or unfinished crap
yes because writing xaml will always be superior
there is no point in making one
telling beginners to just be experts and do expert tier design, is not a real answer.
im not doing that
you kind of are
actually you explicitly are
im telling beginners to learn more so they can do what they want more easily
sorry if that came out condescending
Hey there mr beginner, why don't you just learn to code in multiple languages and build programs from scratch with no coding knowledge. Ah yes, why didn't i think of that. so 'simple'
xaml isnt a programming language
its just for layouts
similar to html
whatever you want to be fancy and call it, its a language of some kind
it is a language of some kind
but its made to make things easier
anyway you dont have to learn right now
im just saying your life will be easier if you write xaml instead of using the designer
anyway, how can i do this...? The entire point is i don't know what trigger to use. I'm asking how to check it.
the same event
just check if the selected item is null
if it is, return (or do whatever idk)
btw xaml isnt just for wpf
hmmm, thats a good idea i suppose :0
its used by the vast majority of .net gui frameworks
i know
but so long as you wanna talk about it
xaml will always be terrible for all beginners
by basically just existing
everything is terrible for beginners
as another language one needs to learn ontop of their primary language
until they learn it
again, its not a programming language
the coding industry just going "fuck beginners" is dumb as hell
its much easier to learn than a programming language
i dont think its going that way
but it's also entirely unnecessary
its not
well, we don't have any good replacements for winforms
it is...
we do, its wpf
wpf has xaml
yes
thats a good thing
and its terrible for beginners
its a bad thing
its harder to learn yes
but it will be worth it
and that makes people quit
people quitting isn't worth it
thats why some people recommend starting out with winforms
then moving to wpf
Yeah, but in order to start with a pure visual builder, we kind of need a new one to exist that didn't end development 2 decades ago
xaml isnt completely non visual
xaml hot reload is a thing
it lets you see changes you make in xaml, in real time, while the app is running
so you know exactly how it will look like, in the actual app
anyway il try a if null
btw do you have nullable reference types enabled?
it a feature than warns you about stuff like this
but youll have to explicitly specify in the declaration whether you want the type to be nullable
well it worked
i don't know why i didn't think of that
probably due to wanting less lines of code so bad i forgot to think about adding more code
yeah more code != bad
readable code == good