我有一个路径形状,我想在路径上方设置一个标签,我在路径上方放置一个文本块,然后我处理Path_MouseEnter,Path_MouseLeave并更改路径背景,当鼠标将路径形状保留为textblock时问题当我处理Path_MouseDown时,背景改变了另一个问题,文本块也出现问题是否有更好的方法在路径形状上方设置标签?
private void Path_MouseEnter(object sender, MouseEventArgs e)
{
(sender as Path).Fill = System.Windows.Media.Brushes.Yellow;
}
private void Path_MouseLeave(object sender, MouseEventArgs e)
{
(sender as Path).Fill = System.Windows.Media.Brushes.LightGray;
}
private void Path_MouseDown(object sender, MouseButtonEventArgs e)
{
}
答案 0 :(得分:1)
您的问题难以理解,但我认为您的意思是TextBlock
覆盖了Path
,并且当鼠标点击文本块时,您的Path_MouseLeave()
是触发但你不想要它?
如果是这种情况,只需在IsHitTestVisible="False"
上设置TextBlock
即可使其对鼠标事件透明。