Visibility of Class field-data of Mouse Clicked ImageButton located within WrapPanel
Posted
by Bill
on Stack Overflow
See other posts from Stack Overflow
or by Bill
Published on 2010-04-05T15:48:11Z
Indexed on
2010/04/05
15:53 UTC
Read the original article
Hit count: 506
I am attempting to obtain the class-data behind an ImageButton that is mouse-clicked; which ImageButton is located within a WrapPanel filled with ImageButtons. The problem I am having is obtaining the visibility of the field data within the class behind the image-button. Although I can see the class, I can neither see nor access the field data. Can anyone please point me in the right direction?
// Handles the ImageButton mouseClick event within the WrapPanel.
private void SolarSystem_Click(Object sender, RoutedEventArgs e)
{
FrameworkElement fe = e.OriginalSource as FrameworkElement;
SelectedPlanet PlanetSelected = new SelectedPlanet(fe);
PlanetSelected.Owner = this;
MessageBox.Show(PlanetSelected.PlanetName);
}
// Used to initiate instance of Class and some field data.
public SelectedPlanet(FrameworkElement fe)
{
InitializeComponent();
string sPlanetName = ((PlanetClass)(fe)).PlanetName;
return sPlanetName
}
// Class Data
public class PlanetClass
{
string planetName;
public PlanetClass(string planetName)
{
PlanetName = planetName;
}
public string PlanetName
{
set { planetName = value; }
get { return planetName; }
}
}
© Stack Overflow or respective owner