WPF TabItem Element MouseClick Event
Solution 1
What are you trying to achieve? It looks like you're trying to trap when the user moves to the tab, if so you can hook a different event SelectionChanged
:-)
Solution 2
I did not want selectionchanged event because that would involve a switch. So i wanted an event directly on the tab clicked.
While i thought an MouseDown event was what I was looking for.... after wiring up all sorts of mouse events with break points; i found the MouseUp events worked for me.
So I used MouseLeftButtonUp
or MouseUp
.
Solution 3
For who really want to use something like MouseLeftButtonDown event, you can use the "MouseUp" event instead. =)
rem
Updated on June 04, 2022Comments
-
rem almost 2 years
In WPF app inside a
TabControl
there is aTabItem
element with oneLabel
. I want to fire the event onMouseClick
on theTab
of thisTabControl
, but the eventMouseLeftButtonDown
:<TabItem Header="Header1" MouseLeftButtonDown="TabItem_MouseLeftButtonDown" > <Label Height="28" Name="AdderLbl" Width="120" Background="Azure" >Label</Label> </TabItem>
fires only on click over the label. It is not wat I want.
How I could fire the event on
MouseClick
over theTab
, not its content?