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 8785239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:18:10+00:00 2026-06-13T21:18:10+00:00

I know this question has been asked many times before, I have found a

  • 0

I know this question has been asked many times before, I have found a few solutions here on line, but I could not make any of them work. I have a few elements on a custom control I have, and I want to put a bound tool tip on one of them. This is what I have so far.

<UserControl x:Class="DirectGraphicsControl.ColorBarView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:DirectGraphicsControl="clr-namespace:Windows.DirectGraphicsControl" mc:Ignorable="d" 
         SizeChanged="UserControlSizeChanged" MinWidth="95">
<DockPanel LastChildFill="True" Width="80" x:Name="_mainDockPanel">
    <TextBlock DockPanel.Dock="Top" x:Name="_title" x:FieldModifier="public" HorizontalAlignment="Center" Margin="0,2,0,2"/>
    <StackPanel Orientation="Vertical" DockPanel.Dock="Bottom" Margin="0,2,0,2"
                    x:Name="_bottomLabelsRegion" x:FieldModifier="public">
        <TextBlock x:Name="_unitName" x:FieldModifier="public" HorizontalAlignment="Center" VerticalAlignment="Bottom"/>
    </StackPanel>
    <Grid DataContext="{Binding ElementName=_mainDockPanel.Parent, Path=MyTooltip}" >
        <DirectGraphicsControl:DirectGraphicsControl x:Name="_directGraphicsControl"
                                                     MouseDoubleClick="HandleColorBarMouseDoubleClick" x:FieldModifier="public">
            <DirectGraphicsControl:DirectGraphicsControl.ToolTip>
                <ToolTip Content="{Binding Path=PlacementTarget.DataContext, 
                                   RelativeSource={RelativeSource Self}}"/>
            </DirectGraphicsControl:DirectGraphicsControl.ToolTip>
        </DirectGraphicsControl:DirectGraphicsControl>
    </Grid>
</DockPanel>

and this is the code behind.

/// <summary>
    /// The tool tip text
    /// </summary>
    public static readonly DependencyProperty TooltipProperty =
        DependencyProperty.Register(Reflection.GetPropertyName<ColorBarView>(m => m.MyTooltip),
                                    typeof(string), typeof(ColorBarView));

    /// <summary>
    /// The tool tip text
    /// </summary>
    public string MyTooltip
    {
        get { return "Test from binding"; }
    }

The code behind property is only returning a hard coded string for now until I can actually get it working and then it will return the calculated value I would like it to. Currently on mouse over an empty box appears. When I add the text for the tooltip straight to the xaml it shows fine. This makes me think it cannot find the location of the binding.

I am very new to wpf so any suggestions would be great.

Thank you,

  • 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-06-13T21:18:12+00:00Added an answer on June 13, 2026 at 9:18 pm

    Try changing the dependency property to:

     public static readonly DependencyProperty TooltipProperty =
        DependencyProperty.Register(Reflection.GetPropertyName<ColorBarView>(m => m.MyTooltip),
                                    typeof(string), typeof(ColorBarView),new PropertyMetadata("Test Value") );
    

    and the binding to:

    <Grid DataContext="{Binding ElementName=_myControl, Path=MyTooltip}" >
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question has been asked many times before, but I haven't found
I know this question has been asked many times here and elsewhere before as
I know this question has been asked many times on here but I have
I know this is a question that has been asked many times before, but
I know this question has been asked so many times before. But I just
I know that this question has been asked many times before in different guises
I know this question has been asked many times and we have gotten this
I know this question has been asked many times before but I can't find
I know this question has been asked many times before, but any of the
I know this question has been asked so many times before but I couldn't

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.