2013-04-20 88 views
0

我有一個路徑形狀,我想設置路徑上方的標籤,我把一個文本塊上面的路徑然後我處理Path_MouseEnter,Path_MouseLeave和更改路徑背景問題是當鼠標離開當我處理Path_MouseDown時,文本塊的背景形狀改變了另一個問題,文本塊也會產生問題嗎?有沒有一種方法可以在路徑形狀上面設置標籤?WPF路徑形狀標題

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) 
    { 

    } 

回答

1

你的問題是難以遵循,但我覺得你的意思是你有一個TextBlock覆蓋在一個Path的頂部,當鼠標點擊的文本塊,你Path_MouseLeave()被觸發,但你不想要它?

如果是這種情況,只需在TextBlock上設置IsHitTestVisible="False"以使其對鼠標事件透明。