Newline/LineBreak not working with ToolTipService.ToolTip

5 posts, 0 answers
  1. Scott
    Scott avatar
    16 posts
    Member since:
    Oct 2013

    Posted 15 Jan 2014 Link to this post

    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?
  2. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 20 Jan 2014 Link to this post

    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 >>
  3. DevCraft banner
  4. Scott
    Scott avatar
    16 posts
    Member since:
    Oct 2013

    Posted 21 Jan 2014 Link to this post

    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.
  5. Scott
    Scott avatar
    16 posts
    Member since:
    Oct 2013

    Posted 21 Jan 2014 Link to this post

    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
  6. Yoan
    Admin
    Yoan avatar
    1066 posts

    Posted 22 Jan 2014 Link to this post

    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 >>
Back to Top
DevCraft banner