✅ Avalonia — stop children from triggering parent events
with the following codebehind
makes it so that clicking on the buttons doesn't trigger their commands, but rather the click gets captured by the parent and the window gets dragged
10 Replies
PointerPressed
being the Avalonia-equivalent of MouseClick
?
seems like it must be a tunneling event, instead of bubbling?
your goal here would be that clicking anywhere ELSE in the stack panel allows you to drag the whole thing, but only if it's empty space?
maybe verify this with some debug logging, cause I fail to see how else this would be the case, other than a bug
arguably, if the event is tunneling instead of bubbling, that in itself could be considered a bugBasically, yeah
definitely doesn't make conventional sense
see if you can debug and figure out how the even is being routed
maybe button commands are tied to some OTHER event?
like, WPF has MouseButtonDown and MouseButtonUp?
Adding
fixed it
eewwwwww
if you're gonna go that route, it ought to be
if (e.Source is not this)
or whatever
that still bugs me, though, bubbling events shouldn't work that waythis
is MainWindow
not StackPanel
then reference it by name
I guess I could do
(e.Source as Control) is { Name: "TopBar" }
or jusy
e.Source == _topBar
_topBar
doesn't exist
e.Source is not StackPanel { Name: "TopBar" }
works fine so I'm just gonna leave it