Is there a way to set textblocks to static on a UserControl in C# before compile?
EDIT: Apparently I was a little confusing. The original post will remain below, but the main thing I'm asking is if there is a way to make a textblock on a usercontrol static, so that when I try to set it's value with a static method, it doesn't whine and say "An object reference is required for the non-static field, method, or property 'WpfApplication10.ProfileControl.blkFirst'".
I'm not sure if I designed my entire database class wrong, but I essentially have a project right now that connects to a remote database. Everything works when I add things to the database. I can add new users (with SHA512 encrypted passwords using salt :D), add "events" that include the title of and event and a date/time, and even basic user information li开发者_运维知识库ke email address, first name, last name, etc.
Everything works when I'm adding to the database. However, I have a usercontrol called Profile and it is supposed to display all of the basic user information, such as the username, email, etc.
The problem, unfortunately, is that the textblocks I'm trying to set values to are not static, but the way all of my other stuff is set up in my database, login, etc controls, it is static. This isn't an issue when I'm adding things to the database, because I'm not directly altering things already on the usercontrol.
It is very possible that I am doing something in my overall design wrong, but I'm hoping that there is a way to make objects static on a usercontrol when you add them in the design view, otherwise I'm going to have to probably go back and change my entire program.
You can't make component controls static on a control, because a control can only have one parent. If you create multiple instances of your control, which instance should the textblocks appear in?
I'm not sure what you mean when you say your existing stuff is static - I'm assuming you're referring to objects in codebehind. If you've made all of those static then I suggest you a) change that and b) find and read some good articles on class/component reuse. All those static variables make your code hard to reuse and poorly-encapsulated, and that will come back to bite you at some point.
If you need more help, you could post some code in your question and get more direct feedback.
精彩评论