Saturday, August 29, 2015

Alright, so a fresh new solution. Adding folders: Models, ServiceClasses, ViewModels, and our view should technically go into the Views folder, but I'll make it simple for this examle and use the default MainPage.xaml that already exists in the root folder of the solution.

Adding the model class, Model.cs into the /Models folder. For the simplicity, there are only two properties.

Class "ShowConverter" is what we will use to show or hide the data based on their values. If it is not clear now how it works, it'll become all clear in the end. Something worth noticing here is that we are extracting the "value" parameter and converting it to an integer, and we are doing the same thing to the "parameter" object. If the values are the same, then whatever we are tying up to this is visible, otherwise it is hidden.

Now, the view. The actual face of the program. First thing to notice is the xmlns:service line in the Page tag. That declares the namespace that we can use, and we declare it to use the converter. The next line is Page.Resources tag, actually what's happening inside it. First declaration is me being lazy -- I set the FontSize of all the TextBoxes at once to 24. The second item is our declaration of the ShowConverter. I declared the namespace in the Page tag to be able to access the file, I actually tell the system what it is under the Resources section. I actually use the file to toggle visibility of an item in the following manner: