开发者

WPF - databinding label on listbox ismouseover

I'm still new to WPF, and I'm trying to do something that's beyond my knowledge at the moment.

I have a listbox databinded to the source collection, and a label. I'd like to bind the label's Content value to the listbox's item over which is mouse hovered.

Say I have DataTemplate binded to the class MenuItem:

<DataTemplate DataType="{x:Type local:MenuItem}" x:Key="MenuListTemplate">

Which has member Text. I want my Label to display Text from element which is mouse overed in list. I have the IsMouseOver trigger开发者_运维技巧 for my textbox, but have no idea how to bind Label.Content to it.

Any tips?


I don't think that binding can achieve your goal with ease. I think it's easier to do with routed events.

Subscribe to the MouseMove event at the ListBox level. Check if the source of the event is a ListBoxItem, and if it is use this item to update the label.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜