Hey
I am new to programming and want to teach myself how to program in C# in Visual Studio. I’ve been going pretty smoothly and have been learning across from sites across the internet, but right now i’e come across a little problem which I cant seem to find a solution to.
I’m making a simple utility using Visual studio and blend and it consists of some custom user controls created via Blend.
One of these user controls is a toggle switch and to identify whether it is on or off, I created a boolean variable
Essentially my goal is to update some text on the screen depending on the value of this Boolean.
The variable for the switch is stored on a file called – ‘ToggleSwitch.xaml.cs‘ [FORM A] and the text I want to update is stored on a file called ‘MainWindow.xaml.cs‘ [FORM B].
How would I go abouts using the boolean variable from [FORM A] and implementing it into code used in [FORM B].
I hope I have explained what I want to do clearly and would really appreciate it if anyone could help me with this.
I’m guessing that your MainWindow class has (at least one) instance of the ToggleSwitch class within. So you’ll want to setup a way for the MainWindow to read the state of the ToggleSwitch class, right? If you’re working in XAML/MVVM your MainWindow would bind to the properties of a ToggleSwitch object. These properties would dictate the state of the
MainWindow class… for example if the ToggleSwitch’s SwitchOn property is false the visibility on a Label should be set to Visbility.Hidden.
Before you get to far into this though, I would spend some time learning about the difference between a class and an object (and a file too based on your question). Make sure you understand this stuff first since it’s paramount to understanding the rest.
Ok Thanks
I’ll take a look into classes and objects
Ok, I looked at some documentation from. W3 schools and Microsoft and learned 2 things.
Most of the terminology I used in the post are completely wrong and
I still have quite a bit to learn in terms of classes and objects and as you said file!