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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:43:58+00:00 2026-05-14T06:43:58+00:00

I am attempting to obtain class-data associated with a mouse-clicked ImageButton; which ImageButton is

  • 0

I am attempting to obtain class-data associated with a mouse-clicked ImageButton; which ImageButton is located within a Scollviewer wrapped WrapPanel and filled with numerous other ImageButtons. The problem is that although I can see the instance of the ImageButton selected “((PlanetClass)(fe))”, and have visibility of the class instance’s underlying data “((PlanetClass)(fe)).Content”, I am unable to access any of the class’s field data. The example below illustrates my intention.

Am I approaching this problem correctly (WrapPanel (wrapped in ScrollViewer)-> ImageButton-> FrameworkElement -> Instance of the Button -> Field Data)? If not, what would the best way be to access the ImageButton instance and the instance’s associated data? Can anyone please point me in the right direction?

// WPF EventHandler at the container level:
<ScrollViewer ButtonBase.Click="SolarSystem_Click">

// Handles the ImageButton mouseClick event within the ScrollViewer wrapping the WrapPanel. 
private void SolarSystem_Click(Object sender, RoutedEventArgs e) 
{ 
    FrameworkElement fe = e.OriginalSource as FrameworkElement; 
    SelectedPlanet PlanetSelected = new SelectedPlanet(fe); 
    MessageBox.Show(PlanetSelected.PlanetName); 
} 

// Used to initiate instance of ImageButton to access field data. 
public SelectedPlanet(FrameworkElement fe) 
{ 
    return ((PlanetClass)(fe)); 
} 

// Class Data 
public class PlanetClass 
{ 
    string planetName; 

    public PlanetClass(string planetName) 
    { 
        PlanetName = planetName; 
    } 

    public string PlanetName 
    { 
        set { planetName = value; } 
        get { return planetName; } 
    } 
} 
  • 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-14T06:43:58+00:00Added an answer on May 14, 2026 at 6:43 am

    TWO DAYS LATER and a lot of frustration:

    After scratching my head for two days on this issue, I figured out that to obtain the underlying data beneath a mouse-clicked ImageButton I needed to cast the FrameworkElement e.OriginalSource back to the original ImageButton to get to it’s “.source”, and then cast the result to PlanetClass to get to it’s properties.

    // WPF EventHandler placed at the container level.
    <ScrollViewer ButtonBase.Click="SolarSystemButton_Click">
    
    // Handles the ImageButton mouseClick event within the ScrollViewer wrapping the WrapPanel. 
     private void SolarSystemButton_Click(Object sender, RoutedEventArgs e)  
         { 
             FrameworkElement fe = e.OriginalSource as FrameworkElement;  
             string PlanetName = ((PlanetClass)((ImageButton)fe).Content).PlanetName;
             return PlanetName;
         }
    

    Bill

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

Sidebar

Related Questions

Attempting to use the amazon API to obtain product data and currently failing miserably.
I am attempting to reformat the data set my.data to obtain the output shown
Attempting to build a C# NPAPI plugin I have found a tutorial which describes
Attempting to use the data series from this example no longer passes the JSONLint
Attempting/struggling to get registration and sign-up working within an active admin project. I have
Attempting to build a C# project which has numerous references to assemblies in NuGet
I'm attempting to create a backup of my client's existing svn repositories, which is
I'm attempting to compile a working copy of the MagickNet class library (DLL) using
I'm attempting to compile SndObj, and I need some header files. Which Debian packages
I am using Reflections to obtain a method from a class that is annotated

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.