Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6978899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:49:01+00:00 2026-05-27T17:49:01+00:00

In my custom control I want to programmaticaly enable or disable tooltip depending on

  • 0

In my custom control I want to programmaticaly enable or disable tooltip depending on options. Here is how my icon defined in template:

<Image x:Name="PART_IconImage" Stretch="None" VerticalAlignment="Top" HorizontalAlignment="Center" Source="{TemplateBinding Icon}" 
                                   ToolTipService.ToolTip="{TemplateBinding Caption}" />

I’m using this code to access ToolTip and to enable/disable it:

// Enable tooltip when caption not shown
            if (this.IconImage != null)
            {
                var toolTip = ToolTipService.GetToolTip(this.IconImage) as ToolTip;

                if (toolTip != null)
                    toolTip.IsEnabled = this.CaptionVisibility.HasValue
                                        ? (this.CaptionVisibility.Value == Visibility.Collapsed)
                                        : (this.ParentToolbar.CaptionsVisibility == Visibility.Collapsed);
            }

GetToolTip returns null. Any idea why?

P.S. I was following this advice here: How to programmatically access ToolTipService of a Silverlight FrameworkElement?
But it doesn’t work for me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:49:02+00:00Added an answer on May 27, 2026 at 5:49 pm

    Are you sure that ToolTipService.GetToolTip is returning null, as opposed to returning something other than a ToolTip?

    I did a quick experiment with code similar to yours and found that ToolTipService.GetToolTip returned a string. I was of course binding ToolTipService.ToolTip to a string dependency property. I suspect you’re also getting a string back from GetToolTip, but the as ToolTip you have added after the call to this method nulls out this string.

    One way to programmatically disable the tooltip is to bind it to a property on the view-model which contains the tooltip text if the tooltip should be shown or null if the tooltip should not be shown.

    Alternatively, you can use a ToolTip, instead of a string, as the tooltip for your control. That way you should be able to access the ToolTip object and enable/disable it in your code above:

    <Image x:Name="PART_IconImage" Stretch="None" VerticalAlignment="Top" HorizontalAlignment="Center" Source="{TemplateBinding Icon}">
        <ToolTipService.ToolTip>
            <ToolTip>
                <TextBlock Text="{TemplateBinding Caption}" />
            </ToolTip>
        </ToolTipService.ToolTip>
    </Image> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a custom control. I want the template for this control to
I want to place an image inside my custom control , so my generic.xaml
I have a custom control (C#, visual studio). I want to show a tooltip
I want to create a custom control for a image regarding the dynamic zoom
I want to create a custom control (partial view, template) and have it function
I have custom control where i want to show some items. In generic.xaml defined
I have a custom control and I want to dynamically insert a link to
I want to create a custom control in C#. But every time I have
I want to double buffer a custom control which contains buttons. I have tried
I want to build a custom control to reuse in my project which consists

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.