2009-04-09 41 views
0

我在我的XAML中使用了事件觸發器,我在ListItem上設置了以下樣式。我想要的是當鼠標進入列表項時,在消息框中顯示ListItem的內容。ListItem鼠標輸入消息框

 <Style.Triggers> 
      <EventTrigger RoutedEvent="Mouse.MouseEnter"> 

      </EventTrigger> 
     </Style.Triggers> 

我想知道是否有可能在鼠標進入listitem後觸發代碼。

回答

3
<ListBox> 
    <ListBox.ItemContainerStyle> 
     <Style TargetType="ListBoxItem"> 
      <EventSetter Event="MouseEnter" Handler="_listBoxItem_MouseEnter"/> 
     </Style> 
    </ListBox.ItemContainerStyle> 
</ListBox> 
+0

嗨肯特,謝謝你的幫助。但是,當我將發件人投到我的自定義對象[Person p = sender as Person];我在對象「p」中得到一個空值。 Person類有一個BitmapImage和一個String,用於保存圖像的信息,並且此信息是我想要在消息框中顯示的信息。任何指針? – 2009-04-09 14:00:41