WPF binding with StringFormat doesn’t work on ToolTips

ToolTips in WPF can contain anything, not just text, so they provide a ContentStringFormat property for the times you just want text. You’ll need to use the expanded syntax as far as I know:

<TextBox ...>
  <TextBox.ToolTip>
    <ToolTip 
      Content="{Binding ElementName=myTextBlock,Path=Text}"
      ContentStringFormat="{}It is: {0}"
      />
  </TextBox.ToolTip>
</TextBox>

I’m not 100% sure about the validity of binding using the ElementName syntax from a nested property like that, but the ContentStringFormat property is what you’re looking for.

Leave a Comment