This is a migrated thread and some comments may be shown as answers.

Newline/LineBreak not working with ToolTipService.ToolTip

4 Answers 122 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 2
Scott asked on 15 Jan 2014, 04:53 PM
So I'm using Silverlight 4 and I've got the following GridViewColumn:

<telerik:GridViewColumn
    UniqueName="CreditIssuesText"
    CellStyle="{StaticResource rgvCellStyle}"
    HeaderCellStyle="{StaticResource rgvHeaderCellStyle}"
    HeaderTextAlignment="Center"
    TextAlignment="Center"
    Width="Auto">
    <telerik:GridViewColumn.CellTemplate>
        <DataTemplate>
            <Image
                Source="/HubSilverlight;component/Images/status_icon_info.png"
                ToolTipService.ToolTip="{Binding CreditIssuesText}"
                Visibility="{Binding CreditIssuesText, Converter={StaticResource TextToVisibilityConverter}}"
                Width="16"
                Height="16" />
        </DataTemplate>
    </telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>

CreditIssuesText is being pulled from our SQL Server where a function concatenates all of the possible credit issues and joins them together with line breaks to be used in a tooltip when hovering over the icon.

I've already tried everything in http://stackoverflow.com/q/183406/682480 to no avail.

  • &#0a;
  • &#0d;
  • &#0a;&#0d;
  • &#10;
  • &#13;
  • &#10;&#13;
  • <br />
  • <LineBreak />
  • \n
  • \r\n

How in the world do I get a line break or newline to work in a bound string that's being pulled from SQL?

4 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 20 Jan 2014, 11:55 AM
Hello Scott,

I have tried the approach from the mentioned Stackoverflow thread and it works as expected. I have attached my test project for a reference. Moreover, I have applied the approach from this MSDN thread as well. 

I hope this helps.

Regards,
Yoan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Scott
Top achievements
Rank 2
answered on 21 Jan 2014, 03:23 PM
Your solution uses Silverlight 5 whereas in my post I said I was using Silverlight 4.  I'm not sure if there would be a difference or not, but I can't open a Silverlight 5 solution.
0
Scott
Top achievements
Rank 2
answered on 21 Jan 2014, 08:07 PM
I was able to solve my issue.

In our SQL database, we store line breaks as \n. I have no idea why or how, but somewhere between the time the data was retrieved from SQL via our WCF service and the time the data was bound to the GridView, the tooltip string was being modified.  All of the \n line breaks were being escaped changing them to \\n.

What I ended up doing to resolve the issue was make a simple converter that replaced \\n with Environment.NewLine

To see my full solution along with 2 other problems I ran into afterwards and their solutions, take a look at my accepted answer to this same question I created on StackOverflow:

http://stackoverflow.com/q/21142069/682480
0
Yoan
Telerik team
answered on 22 Jan 2014, 01:43 PM
Hello Scott,

I am glad to hear that you have resolved the issue. 

Thank you for sharing the solution with the community.


Regards,
Yoan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Scott
Top achievements
Rank 2
Answers by
Yoan
Telerik team
Scott
Top achievements
Rank 2
Share this question
or