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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:15:53+00:00 2026-06-01T23:15:53+00:00

My application uses WPF for the presentation layer. I have a UserControl in my

  • 0

My application uses WPF for the presentation layer. I have a UserControl in my code, whose XAML is shown below:

<UserControl x:Class="CarSystem.CustomControls.ReadPushPin"
             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:cs="clr-namespace:CarSystem.CustomControls"
             mc:Ignorable="d"
             DataContext="{Binding Path=Read, RelativeSource={RelativeSource Self}}"
             d:DesignHeight="30"
             d:DesignWidth="30">

    <UserControl.Resources>
        <cs:BooleanToVisibilityConverter x:Key="BoolToVisibility" True="Visible" False="Collapsed" />
        <cs:DateConverterForRadDateTimePicker x:Key="DateConverter" />
    </UserControl.Resources>

    <Image Name="MarkerImage"
           Source="{Binding Path=Source, RelativeSource={RelativeSource AncestorType={x:Type cs:ReadPushPin}}}">
        <Image.ToolTip>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Image Grid.Column="0"
                       Grid.ColumnSpan="2"
                       Grid.Row="0"
                       Height="45"
                       HorizontalAlignment="Center"
                       Source="{Binding Path=ThumbnailImage, RelativeSource={RelativeSource AncestorType={x:Type cs:ReadPushPin}}}"
                       Visibility="{Binding Converter={StaticResource BoolToVisibility}, Path=HasThumbnail, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type cs:ReadPushPin}}}"
                       Width="60" />
                <TextBlock Grid.Column="0"
                           Grid.Row="1"
                           HorizontalAlignment="Right"
                           Text="Plate:" />
                <StackPanel Grid.Column="1"
                            Grid.Row="1"
                            HorizontalAlignment="Left"
                            Orientation="Horizontal">
                    <TextBlock Text="{Binding Path=Plate}" />
                    <TextBlock Text=", " />
                    <TextBlock Text="{Binding Path=State}" />
                </StackPanel>
                <TextBlock Grid.Column="0"
                           Grid.Row="2"
                           HorizontalAlignment="Right"
                           Text="Time:" />
                <TextBlock Grid.Column="1"
                           Grid.Row="2"
                           HorizontalAlignment="Left"
                           Text="{Binding Converter={StaticResource DateConverter}, Path=TimeStamp}" />
                <TextBlock Grid.Column="0"
                           Grid.Row="3"
                           HorizontalAlignment="Right"
                           Text="Nearest Address:" />
                <TextBlock Grid.Column="1"
                           Grid.Row="3"
                           HorizontalAlignment="Left"
                           Text="{Binding Path=NearestAddress, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type cs:ReadPushPin}}}" />
                <TextBlock Grid.Column="0"
                           Grid.Row="4"
                           HorizontalAlignment="Right"
                           Text="Cross Street:" />
                <TextBlock Grid.Column="1"
                           Grid.Row="4"
                           HorizontalAlignment="Left"
                           Text="{Binding Path=CrossStreet, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type cs:ReadPushPin}}}" />
            </Grid>
        </Image.ToolTip>
    </Image>
</UserControl>

There are a number of DependencyProperties defined in the code-behind that are bound to the various controls in the Image’s ToolTip property.

My problem is that the bindings on the ThumbnailImage, HasThumbnail, NearestAddress, and CrossStreet properties aren’t working. I see errors like the following in the Debug Output window when the program runs:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='CarSystem.CustomControls.ReadPushPin', AncestorLevel='1''. BindingExpression:Path=CrossStreet; DataItem=null; target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')

What am I doing wrong? How do I get the bindings to work?

Tony

  • 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-01T23:15:54+00:00Added an answer on June 1, 2026 at 11:15 pm

    I believe that the problem has to do with the ToolTip not being in the same visual tree as the control it belongs to.

    I solved the problem by adding properties to the view model object for each control in the ToolTip template. As I needed to include a thumbnail image, and I’m storing images in my database as byte arrays, I wrote a class that implements IValueConverter that converts a byte array into a BitmapImage.

    This all works. Thanks anyways.

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

Sidebar

Related Questions

I have a WPF application which uses some library code for authentication which needs
I have a chromeless button in a WPF application that uses the XAML style
I have an application that uses WPF Composite, and I have an issue. I've
I have a fairly large application that uses WPF for its user interface. I
I've got a WPF application which uses the MVVM pattern throughout, no code-behind, the
I have a simple WPF application that uses ClickOnce to handle installing. Within this
I have a desktop .NET WPF application witch uses an embedded database (SQLite). Where
I have a C# WPF application which uses Excel interop libraries to generate and
My .NET 4 application uses the WPF TreeView which I have enhanced to enable
I have a WPF application which uses a JumpList (Recent only). Everything works perfectly

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.