{"id":1280,"date":"2023-03-15T10:54:55","date_gmt":"2023-03-15T10:54:55","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=1280"},"modified":"2023-03-15T10:58:32","modified_gmt":"2023-03-15T10:58:32","slug":"determining-which-object-called-method","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/objects-uwp-programming-in-c\/determining-which-object-called-method","title":{"rendered":"Determining which object called method"},"content":{"rendered":"\n<p>E.g. you have a method like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private async void EditComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)\n{<\/code><\/pre>\n\n\n\n<p>You can detect which object (ComboBox in this example) triggered it with this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\tvar PageObject = sender as ComboBox;\n\n\tif (PageObject.Name == \"MyObjectName\")\n\t{\n\n\t}<\/code><\/pre>\n\n\n\n<p>If you use names that include an ID value, say:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\tvar PageObject = sender as ComboBox;\n\n\tif (PageObject.Name.Contains(\"MyObjectName\"))\n\t{\n\t\tstring sThisObjectId = PageObject.Name.Substring(12);            \/\/Convert \"MyObjectName14\" to \"14\"\n\n\t}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>E.g. you have a method like this: You can detect which object (ComboBox in this example) triggered it with this: If you use names that include an ID value, say:<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[120],"tags":[],"class_list":["post-1280","post","type-post","status-publish","format-standard","hentry","category-objects-uwp-programming-in-c"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1280","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=1280"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1280\/revisions"}],"predecessor-version":[{"id":1284,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1280\/revisions\/1284"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=1280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=1280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=1280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}