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

  • Home
  • SEARCH
  • 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 6752859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:05:37+00:00 2026-05-26T13:05:37+00:00

I’m trying to pass a TextBlock to a converter through binding <DataTemplate> <Grid> <DockPanel

  • 0

I’m trying to pass a TextBlock to a converter through binding

<DataTemplate>
    <Grid>
        <DockPanel LastChildFill="False" x:Name="dpInfo">
            <Image Source = "{Binding Data.Picture}" Height="42" HorizontalAlignment="Left" Stretch="Uniform" VerticalAlignment="Center" Width="32" Margin="16,0,0,0" DockPanel.Dock="Left"/>
            <TextBlock Text= "{Binding Data.Name}" x:Name="tbUserName" VerticalAlignment="Center" Padding="10,0,0,0" TextTrimming="CharacterEllipsis" DockPanel.Dock="Left"/>
            <TextBlock Text=  "{Binding Data.ScribbleCount, StringFormat=' ({0})', Mode=TwoWay}" VerticalAlignment="Center" DockPanel.Dock="Left"/>
        </DockPanel>
        <Rectangle x:Name="rctClickableArea" MouseLeftButtonDown="User_MouseLeftButtonDown" Fill="Black" Opacity="0">
            <Rectangle.ToolTip>
                <ToolTip DataContext="{Binding Path=PlacementTarget.DataContext, RelativeSource={x:Static RelativeSource.Self}}">
                    <ToolTip.Visibility>
                        <MultiBinding Converter="{StaticResource TooltipVisibilityConverter}">
                            <MultiBinding.Bindings>
                                <Binding Path="Data.Name"/>
                                <Binding ElementName="tbUserName"/>
                            </MultiBinding.Bindings>
                        </MultiBinding>
                    </ToolTip.Visibility>

                    <TextBlock Text="{Binding Data.Name}"/>

                </ToolTip>
            </Rectangle.ToolTip>
        </Rectangle>
    </Grid>
</DataTemplate>

The binding to the DataContext (Binding Path=”Data.Name”) works but the binding (Binding ElementName=”tbUserName”) does not work, where tbUserName is a TextBlock in the dbInfo DockPanel. Do you have any ideas on how to bind this correctly?

  • 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-26T13:05:38+00:00Added an answer on May 26, 2026 at 1:05 pm

    You might be having two issues…

    NameScoping …

    ElementName binding has stringent restrictions about NameScoping…

    Basically, when an ElementName is used
    in a binding, the NameScope of the target object is used to locate the
    element with the specified name. If that element doesn’t have a
    NameScope specifically on it, the FrameworkElement.FindScope method
    continues up the logical tree and falls back to the inheritance
    context if there is no logical parent. The name scope is the object in
    which all named objects have been registered.

    So in your case referring element outside the ToolTip’s context fails. Now for this to work correct you will have to bridge the broken scope using something like Tag property…

     <Rectangle Tag="{Binding ElementName tbUserName}" ...>
        <Rectangle.ToolTip>
           <ToolTip ...>
              <ToolTip.Visibility ... >
                 <MultiBinding>
                     <Binding Path="Data.Name" />
                     <Binding Path="Tag"
                              RelativeSource="{RelativeSource
                                 AncestorType={x:Type Rectangle}}" ...>
    

    Visibility of ToolTip

    Instead of binding to visibility of tooltip, you could use a data-trigger with multi binding on rectangle itself and set the tooltip that you want, based on the condition value…

        <Window.Resources>
           <local:TooltipVisibilityConverter x:Key="TooltipVisibilityConverter"/>
           <TextBlock x:Key="MyToolTip" Text="{Binding Data.Name}"/>
         </Window.Resources>
    
        <!-- Rest of the code --->
    
        <Rectangle.Style>
            <Style TargetType="{x:Type Rectangle}">
                <Style.Triggers>
                    <DataTrigger Value="True">
                        <DataTrigger.Binding>
                              <MultiBinding
                                    Converter="{StaticResource
                                       TooltipVisibilityConverter}">
                                    <MultiBinding.Bindings>
                                        <Binding Path="Data.Name"/>
                                        <Binding ElementName="HelloTB"/>
                                    </MultiBinding.Bindings>
                                </MultiBinding> 
                            </DataTrigger.Binding>
                            <Setter Property="ToolTip"
                                    Value="{StaticResource MyToolTip}"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
        </Rectangle.Style>
    

    Notice that TooltipVisibilityConverter now returns a boolean for sake of simplicity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I am trying to render a haml file in a javascript response like so:

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.