简体   繁体   English

如何在现有的tabcontrol上触发IsMouseOver?

[英]How to trigger IsMouseOver on existing tabcontrol?

How can I trigger the IsMouseOver property in an existing WPF TabControl? 如何在现有WPF TabControl中触发IsMouseOver属性? 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#? 也许通过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>

You can use the MouseMove event and then check the mouse.X and mouse.Y position. 您可以使用MouseMove事件,然后检查mouse.X和mouse.Y的位置。 Then get the tabcontrol header location and compare it with the mouse position. 然后获取tabcontrol标头位置并将其与鼠标位置进行比较。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM