开发者

Accessing ImageButton Contents

开发者 https://www.devze.com 2022-12-26 04:21 出处:网络
I am representing a Solar-System\'s planets with ImageButtons that show the planet\'s image on the surface of the button, and hold the planet\'s important data.. name, distance from sun, etc within an

I am representing a Solar-System's planets with ImageButtons that show the planet's image on the surface of the button, and hold the planet's important data.. name, distance from sun, etc within an instance of a Planet class, stored within the ImageButton.Content property. When the ImageButton is selected, I am attempting to access and display the Planet class's data for the selected Planet. Although ((Ima开发者_运维技巧geButton)e.OriginalSource).Content permits viewing all of the Planet class's properties in the debugger, I haven't figured out how to access the Planet class properties directly, as in Pluto.DistanceFromTheSun? Is it possible to access the Planet class information held in the ImageButton contents directly?


Presumably you just need another cast:

((Planet)((ImageButton)e.OriginalSource).Content).DistanceFromTheSun

where Planet is the class that Pluto is.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号