How to set a PlacementTarget for a WPF tooltip without messing up the DataContext?

前端 未结 3 2194
离开以前
离开以前 2021-02-10 18:19

I have a typical MVVM setup of Listbox and vm + DataTemplate and item vm\'s. The data templates have tooltips, which have elements bound to the item vm\'s. All works great.

3条回答
  •  醉酒成梦
    2021-02-10 18:46

    As I understand [but I probably wrong (no harm in trying)], you can initialize your items with reference to objects which were used in ancestor DataContext, i.e.

    public class ItemsVM : VMBase
    {
         public T parentElement;
         public ItemsVM (T _parentElement)
         {
             this.parentElement = _parentElement;
         }
    
         ...
    
    }
    

提交回复
热议问题