How to access a control in a custom style from code behind in silverlight?

The only way to access this is to navigate the visual tree to locate the image. Using Linq-To-VisualTree you can locate it as follows.

The only way to access this is to navigate the visual tree to locate the image. Using Linq-To-VisualTree, you can locate it as follows: using LinqToVisualTree private void Button_Click(object sender, EventArgs e) { Button button = sender as Button; Image img = button.Descendants().Single() as Image; img. Source = "..." }.

Thank you for your response. I thought there may be a simplier way to do it and looking for that. – EEE Dec 20 '11 at 9:58 Unfortunately not.

However, a better approach might be to create your own Button subclass that exposes the Image Source as a dependency property. – ColinE Dec 20 '11 at 10:08 How can I do that. Could you post sample code?

– EEE Dec 20 '11 at 10:19.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions