Setting Tooltips only for longer text width WPF COMBO

Apr 16 2015 5:58 AM
Hi,
 
I am creating a WPF application. My application has a WPF combo box in which i am embedding a Text block in it.
 
I am filling some items to the combo. My question is i want the combo box to display full text for the text whom length is smaller than the combo width, and for the longer widths i need to display the text followed by dots.
 
I am able to fill in the contents to the combo and also able to set the tooltip. My question is i want to enable the tooltip only for longer texts and NOT for shorter texts.  How to add the conditional check ?
 
Code
 
for (int count = 0; count < 100; count++)
{
TextBlock textBlock = new TextBlock
{
Text = count
Width = combobox.Width - 30,
};
 
textBlock.ToolTip = textBlock.Text;
combobox.Items.Add(textBlock);
}

Answers (1)