WPF Binding to Tooltip

前端 未结 4 1349
误落风尘
误落风尘 2021-02-13 01:37

Not sure whats doing here, but the binding works for the label in the data template but not the tool tip. Any help will be appreciated.

                    

        
4条回答
  •  你的背包
    2021-02-13 02:03

    Tooltip is a popup. Sometimes it needs to display out side of your main window bounds. So tooltip can't be in your main visual tree. If you look at its visual tree hierarchy, you will find that popup has its own visual tree root. That's why tooltip isn't aware of the list item's DataContext automatically. Now the question becomes how to propagate the DataContext to tooltip's visual tree. The way you demonstrated in your UPDATE is one way of doing it...

提交回复
热议问题