How to trigger IsMouseOver on existing tabcontrol?

62 Views Asked by At

How can I trigger the IsMouseOver property in an existing WPF TabControl? I tried making a Style but it only creates a new Tab. I want to apply it on the tabs I've already made.What basically i wanna do is to edit the background of the header when the mouse is located over it.

Is there a way to do it? Maybe through c#?

<TabControl HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Width="100">
  <TabItem Header="AddItem">
    <Grid Background="#FFE5E5E5" />
  </TabItem>
  <TabItem Header="UpdateItem">
    <Grid Background="#FFE5E5E5" />
  </TabItem>
</TabControl>
1

There are 1 best solutions below

1
Zero On

You can use the MouseMove event and then check the mouse.X and mouse.Y position. Then get the tabcontrol header location and compare it with the mouse position.