When I create a WPF application in VS 2010 and place a button in Grid I can access the control from C# code. I have the button class instance variable with the same name as in XAML “name” field.
But I can’t see the instance of the control when I create a WPF project using VS 2012 RC.
What can be the problem ? Is there any default project settings difference between VS 2010 and 2012 ?
When I create a WPF application in VS 2010 and place a button in
Share
If you’re talking about codebehind then you should be able to access to the button without declaring it again just by using it’s
x:nameattribute. Now, if you’re talking about MVVM, then you should set your datacontext before using the button.When I’m using 2012 (Release Candidate) I get no intellisense for the codebehind cs files when trying to access elements declared in the xaml (I have to wrote the code without it) and it even suggest there’s no element by that name but project compiles and works. So I’ll suggest you to try to write the code without intellisense and compile it.
I guess this is by default in VS 2012 to encourage use of MVVM but that’s no more than thoughts.