如何将 ListBox 的 *ToolTip* 绑定(bind)到 DataTable?
只有ListBox.ItemsSource,没有ListBox.ToolTip.ItemsSource。
请您参考如下方法:
ToolTip 是一个 ContentControl,而不是一个 ItemsControl。这意味着它只能包含单个元素而不是集合。
要在 ToolTip 中显示多个项目,您需要将一些 ItemsControl(例如 ListBox)放入 TabControl,然后使用其 ItemsSource 属性。
ListBox list = new ListBox();
ToolTip tooltip = new ToolTip();
ListBox tooltipList = new ListBox();
list.ToolTip = tooltip;
tooltip.Content = tooltipList;
tooltipList.ItemsSource = /*your source*/
