January 26th, 2009, 10:40 AM
Accessing a control from a button click - C#
I've just started looking at WPF after playing with C# for a while. As such I'm starting by using XAML to define my form and then use C# to do the interesting stuff behind. For my first example I have a button on a form - Window1 and I can capture the event in the cs file that sits behind the XAML - Window1.xaml.cs. From here I can modify the button if I want to using code like:
private void button1_Click(object sender, RoutedEventArgs e)
Button source = e.Source as Button;
source.Background = Brushes.LemonChiffon;
But say I want the button click to modify another control on the form? How would I change the background value of (say) Button2? I've looked around the web and on MSDN and I can't find anyone who seems to be able to answer this question. I guess it can't be that hard - it's childs play in a "normal" C# form!
Thanks for your help,
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!