如何綁定ListBox的 * 工具提示 *到DataTable?如何以編程方式將ListBox.Tooltip綁定到DataTable?
只有ListBox.ItemsSource
,但沒有ListBox.ToolTip.ItemsSource
。
如何綁定ListBox的 * 工具提示 *到DataTable?如何以編程方式將ListBox.Tooltip綁定到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*/
你可能想嘗試以下操作:
WPF Show data from multiple DataContexts in ToolTip of ItemsControl
上面的鏈接包含了更先進的方案,但它可以用來提取您的實現所需要的代碼。
希望它有幫助!
讓我知道它,你想添加工具提示列表框項目? – xsari3x