{"id":815,"date":"2019-02-15T11:16:06","date_gmt":"2019-02-15T11:16:06","guid":{"rendered":"https:\/\/ibex.tech\/windows-iot\/?p=815"},"modified":"2022-09-13T14:54:59","modified_gmt":"2022-09-13T13:54:59","slug":"passing-page-axml-objects-to-methods","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/windows-and-pages\/pages\/passing-page-axml-objects-to-methods","title":{"rendered":"Passing Page AXML Objects To Methods"},"content":{"rendered":"\n<p>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.<\/p>\n\n\n\n<p>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&#8217;t do this using a global class but you can using class that you simply add locally to each page.  For example, we&#8217;ll create a class called AppPageHelpers.<\/p>\n\n\n\n<p>In each page:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\tprivate AppPageHelpers PageHelpers;\n\n\/\/In the constructor:\n\tPageHelpers = new AppPageHelpers();\n\n\/\/In the page Loaded method for example:\n\tPageHelpers.CheckboxButtonSetStateFromConfig(MyAxmlButtonName);<\/code><\/pre>\n\n\n\n<p>The method in AppPageHelpers that you call from your pages<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public void CheckboxButtonSetStateFromConfig(Button Button1)\n{\n    switch (Something)\n    {\n    case 0:\n        Button1.Content = \"A\";\n        return;\n    default:\n        Button1.Content = \"B\";\n        return;\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[128,75],"tags":[],"class_list":["post-815","post","type-post","status-publish","format-standard","hentry","category-methods-uwp-programming-in-c","category-pages"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/815","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=815"}],"version-history":[{"count":1,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/815\/revisions"}],"predecessor-version":[{"id":1161,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/815\/revisions\/1161"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}