简体   繁体   English

将工具提示添加到组合框项目

[英]Adding tooltips to combobox items

So I was wondering if it's possible. 所以我想知道是否有可能。 I know you can do it in XAML, but I'm adding the combobox items programmatically so that isn't a possibility. 我知道您可以在XAML中做到这一点,但是我以编程方式添加了组合框项目,因此这是不可能的。

It misses details in your question (part of code), but I will try to answer it because I can not add a comment. 它错过了您的问题(代码的一部分)的详细信息,但是由于我无法添加注释,因此我将尝试回答它。

If you add your item by code behind, you can add a tooltip like this : 如果您通过代码在后面添加商品,则可以添加如下工具提示:

ComboBoxItem it = new ComboBoxItem();
it.Content = "Text in list";
it.ToolTip = "your tooltip text";
cb.Items.Add(it);

In this case, cb is your combobox 在这种情况下,cb是您的组合框

If you can use this solution, can you tell how you add your item in your combobox ? 如果可以使用此解决方案,能否告诉您如何在组合框中添加项目?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM