RadPane Header Tooltip from code behind

6 posts, 0 answers
  1. Dean Wyant
    Dean Wyant avatar
    46 posts
    Member since:
    Nov 2009

    Posted 12 Sep 2011 Link to this post

    I am using abreviated text for the Header/Title and I am trying to set the tooltip for the Header and the tab to the complete text.

    I know the TitleTemplate, HeaderTemplate can be used to add tooltips for the title bar and tabs using xaml. However, I need to set tooltips in C# code.

    I can add a tooltip to the tab in code behind by

    ToolTipService

     

     

    .SetToolTip(MyRadPane, Tip);

     

    I cannot find a DependencyObject (PaneHeader?) that I can access to set a tooltip for the Header text area.

    How do I add a tooltip to the title bar Header text area from code behind?

  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 15 Sep 2011 Link to this post

    Hello Dean,

    You could set the template of the header in code behind and add there the tooltip. In that way you will be able to
    set the ToolTip in code behind.

    Hope this information helps.

    All the best,
    Konstantina
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Dean Wyant
    Dean Wyant avatar
    46 posts
    Member since:
    Nov 2009

    Posted 16 Sep 2011 Link to this post

    I know I can set the tooltip in a template like so: 

    The resource is:

     

     

    <DataTemplate x:Key="MyTabTemplate">

     

     

     

    <ContentPresenter Content="{Binding}" Margin="2,0,0,0" >

     

     

     

    <ToolTipService.ToolTip>

     

     

     

    <ToolTip Content="{Binding}"></ToolTip>

     

     

     

    </ToolTipService.ToolTip>

     

     

     

    </ContentPresenter>

     

     

     

    </DataTemplate>

     


    Code:
    HeaderTemplate = ((MainPage)App.Current.RootVisual).Resources["MyTabTemplate"] as DataTemplate;

    More code:
    string sTip = "My Tooltip is dynamic: " + dynamicTip;

    ToolTipService

     

     

    .SetToolTip(this, sTip); // Sets the tab tooltip
    ToolTipService.SetToolTip(?, sTip); // How do I set the header tooltip????

    >>>that way you will be able to
    set the ToolTip in code behind.

    How???

    Thanks.

     






  5. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 21 Sep 2011 Link to this post

    Hi Dean,

    Setting the tooltip from code behind is very difficult task. Instead I can suggest you the following solution:
    - using the MVVM approach define a property for the content of the ToolTip or for the Text property of a TextBlock in the Tooltip.
    - define both HeaderTemplate and TitleTemplate in XAML and add there the ToolTip.
    - when you need to change the value of the Tooltip just change the properties in the ViewModel instead of the DataTemplates themselves.

    Best wishes,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  6. Dean Wyant
    Dean Wyant avatar
    46 posts
    Member since:
    Nov 2009

    Posted 22 Sep 2011 Link to this post

    Unfortunately, I do not know how to do that.
  7. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 26 Sep 2011 Link to this post

    Hi Dean,

    Please find attached a sample project in which this is illustrated.

    Hope this helps.

    Greetings,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Back to Top
DevCraft banner