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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:31:40+00:00 2026-06-08T22:31:40+00:00

I currently have a datagrid that goes and gets results from my database based

  • 0

I currently have a datagrid that goes and gets results from my database based on a server file structure. So, we create PDFs and PPTs, load them into the directory, and add them to that database accordingly. Then a user can search for what they need and the results get displayed in my datagrid. There are two columns that have image hyperlink buttons relating to each PDF and PPT for that particular piece.

Then, when a user clicks the PDF icon or PPT icon, it brings up the high-res piece in another window. No problems there, but now I want it so that when a user hovers over the icon, it brings up a preview of the high res piece inside the tooptip. I can hard code images into the tooltip no problem. So in that aspect we created little thumbnail preview images of each PDF/PPT. They are all sized correctly and ready to go, I just need to bind the location to the tooltip so that it basically shows a ‘thumbnail’ preview for each high-res document.

Here is my XAML:

<sdk:DataGridTemplateColumn x:Name="imageColPdf" Header="PDF" Width="SizeToHeader" IsReadOnly="False">
   <sdk:DataGridTemplateColumn.CellTemplate>
           <DataTemplate>
               <HyperlinkButton HorizontalAlignment="Center" VerticalAlignment="Center" DataContext="{Binding Path=FileName}" Click="HyperlinkButtonPDF_Click" >
                     <Image Source="/PrintOnDemand;component/Images/16x16/page_white_acrobat.png" Stretch="None"  HorizontalAlignment="Center" ></Image>
                          <ToolTipService.ToolTip>
                              <ToolTip>
                                   <ToolTip.Content>
                                       <Image DataContext="{Binding Path=FileName}" Name="LoadPDFImage" Loaded="PDFImageToolTip"/>
                                   </ToolTip.Content>
                               </ToolTip>
                           </ToolTipService.ToolTip>
                       </HyperlinkButton>
                   </DataTemplate>
               </sdk:DataGridTemplateColumn.CellTemplate>
           </sdk:DataGridTemplateColumn>

Then here is the code-behind for the tooltip loaded image event:

private void PDFImageToolTip(object sender, RoutedEventArgs e)
    {

        string docname = ((System.Windows.FrameworkElement)((e.OriginalSource as Image).DataContext)).ToString();
        string baseUri = "http://localhost:51840/ShowDocument.aspx?DocumentName=" + docname + "&type=pdfjpg";
        var hostingWindow = HtmlPage.Window;
        hostingWindow.Navigate(new Uri(baseUri, UriKind.Absolute), "_blank");
    }

I did this method on the click event to call the high res documents, but when i try to load the images through the tooltip, I am getting an error every time I debug (System.NullReferenceException) and object reference not set to an instance of an object.
It seems to not be able to get the correct filename/source path of the image. It fails every time on the string docname. Ok so, my question is, how can I get it to properly go through and display the image we already have set up.

  • 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-08T22:31:41+00:00Added an answer on June 8, 2026 at 10:31 pm

    It looks like you are casting DataContext to a FrameworkElement before calling ToString(), Is that intended?

    string docname = ((System.Windows.FrameworkElement)((e.OriginalSource as Image).DataContext)).ToString();

    Also sender in this handler should be your Image instance. Perhaps this will serve you better:

    String docname = ((FrameworkElement)sender).DataContext.ToString()
    

    Next, the DataContext Binding on HyperLinkButton is certainly not doing you any favours. You should remove it altogether. Presently, the Binding will be looking for a FileName property on your FileName string.

    Alternatively, remove the DataContext binding from Image and it should work.

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

Sidebar

Related Questions

Currently have a drop down menu that is activated on a hover (from display:none
Currently I have a DataGrid, and a datasource. The Datasource is directly pulled from
Currently i have a datagrid view that displays names in the 1st columnnd in
I used to have a class in 1.1 for the Datagrid that inherited from
I have a WPF app that is currently driven completely from XAML. All fields,
I have a DataGrid that is automatically fed certain values from an LINQ-To-SQL-Source. The
I currently have a Combo box that has data that is bind from a
Currently i'm retrieving data from my database which is stored in a datagrid. I
I have a custom control that inherits from a datagrid. I have to evaluate
Currently I have the following code to flash a DataGrid cell when it's value

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.