tags:

views:

126

answers:

1

Hi folks,

In my Silverlight 3 application, I created a custom Tooltip, that is shown when the mouse is over a part of a Pie-Chart. The displayed values are set via TemplateBinding:

<ToolTipService.ToolTip>
  <StackPanel>
    <ContentControl Content="{TemplateBinding IndependentValue}" FontWeight="Bold" />
    <ContentControl Content="{TemplateBinding FormattedDependentValue}"/>
    <ContentControl Content="{TemplateBinding FormattedRatio}"/>
  </StackPanel>
</ToolTipService.ToolTip>

The tooltip shows the title of the pie-slice, the value that the size of the slice is based on and the percentage regarding the whole pie:

MyTitel

9

12%

Now, I want to add a constant string to the value, to show the following:

MyTitel

9 items

12%

the string 'items' shall be added to the displayed number. Is there a way to add the constant string to the Content-Property of the ContentControl? (I have no influence on the binded value FormattedDependentValue)

Thanks in advance, Frank

+1  A: 

Unfortunately, Silverlight does not have the StringFormat property for the binding expression. I see two ways to solve your problem:

  1. Include an horizontal StackPanel in your markup to add a TextBlock with the value 'Items'. This is not 100% what you requested but it works.

  2. Add a converter to the bound value. This converter, in the Convert method, adds the 'Items' constant. This could be used to implement something equivalent to the StringFormat property by the way. See Tim Heuer

Timores
I have solved it by adding the StackPanel. Thanks a lot!
Aaginor