You may want to setup page objects using global methods you can call from within your page, for instance maybe you have a bespoke button you are using in some particular way across many pages in your application.

So you want to be able to call a method, passing a pages Button object to the method for it to manipualte it in some way. You can’t do this using a global class but you can using class that you simply add locally to each page. For example, we’ll create a class called AppPageHelpers.

In each page:

	private AppPageHelpers PageHelpers;

//In the constructor:
	PageHelpers = new AppPageHelpers();

//In the page Loaded method for example:
	PageHelpers.CheckboxButtonSetStateFromConfig(MyAxmlButtonName);

The method in AppPageHelpers that you call from your pages

public void CheckboxButtonSetStateFromConfig(Button Button1)
{
    switch (Something)
    {
    case 0:
        Button1.Content = "A";
        return;
    default:
        Button1.Content = "B";
        return;
    }
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *