Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 29
  • Last Modified:

C# WPF functionality

Could anybody help, I need to call a method in main window from a WPF user control and I changed this method to "static" and now for all field involved in this method I also got a message "an object reference is required for the non-static field method or property".
How can I resolve this?
0
ybt
Asked:
ybt
  • 3
  • 3
2 Solutions
 
AndyAinscowFreelance programmer / ConsultantCommented:
Simply by changing it back to what it was originally.  The 'static' keyword should only be used if it is really needed.  You can probably do what you want without having to make a major underlying change as to how things operate (by using static) in the background.
0
 
ybtAuthor Commented:
By changing it back, how can I call it from WPF user control?
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
Have a look at the following.  I think it will supply all the information you need.
http://stackoverflow.com/questions/25020916/interaction-between-two-usercontrols-in-wpf-without-using-mvvm
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
AndyAinscowFreelance programmer / ConsultantCommented:
You need to use events to communicate
Also look at
https://msdn.microsoft.com/en-us/library/ff725477(v=expression.40).aspx
0
 
ybtAuthor Commented:
It makes exactly what I needed.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now