If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Accessing a control from a button click - C#

Hi all,

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:

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!

Re: Accessing a control from a button click - C#

Hi all,

I can't believe I have been so stupid! Accessing the control is EXACTLY the same as using a Windows Form! Apologies for wasting everyones time - and to think I spent an hour trying to work this out - D'Oh!

Re: Accessing a control from a button click - C#

Accessing the control is not exactly the same. You will learn. I am learning as well. Consider "attached properties" and "dependency properties". WPF is a completely different beast from your comfortable .net experience.